Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/context/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('context/App.tsx', () => {
const markNotificationDoneMock = jest.fn();
const unsubscribeNotificationMock = jest.fn();
const markRepoNotificationsMock = jest.fn();
const markRepoNotificationsDoneMock = jest.fn();

beforeEach(() => {
(useNotifications as jest.Mock).mockReturnValue({
Expand All @@ -56,6 +57,7 @@ describe('context/App.tsx', () => {
markNotificationDone: markNotificationDoneMock,
unsubscribeNotification: unsubscribeNotificationMock,
markRepoNotifications: markRepoNotificationsMock,
markRepoNotificationsDone: markRepoNotificationsDoneMock,
});
});

Expand Down Expand Up @@ -234,6 +236,40 @@ describe('context/App.tsx', () => {
);
});

it('should call markRepoNotificationsDone', async () => {
const TestComponent = () => {
const { markRepoNotificationsDone } = useContext(AppContext);

return (
<button
type="button"
onClick={() =>
markRepoNotificationsDone(
'gitify-app/notifications-test',
'github.com',
)
}
>
Test Case
</button>
);
};

const { getByText } = customRender(<TestComponent />);

markRepoNotificationsDoneMock.mockReset();

fireEvent.click(getByText('Test Case'));

expect(markRepoNotificationsDoneMock).toHaveBeenCalledTimes(1);
expect(markRepoNotificationsDoneMock).toHaveBeenCalledWith(
{ enterpriseAccounts: [], token: null, user: null },
mockSettings,
'gitify-app/notifications-test',
'github.com',
);
});

it('should call validateToken', async () => {
apiRequestAuthMock.mockResolvedValueOnce(null);

Expand Down