Skip to content

Commit ce8d6ba

Browse files
authored
test: markRepoNotificationsDone (#1155)
1 parent c5447fb commit ce8d6ba

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/context/App.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('context/App.tsx', () => {
4848
const markNotificationDoneMock = jest.fn();
4949
const unsubscribeNotificationMock = jest.fn();
5050
const markRepoNotificationsMock = jest.fn();
51+
const markRepoNotificationsDoneMock = jest.fn();
5152

5253
beforeEach(() => {
5354
(useNotifications as jest.Mock).mockReturnValue({
@@ -56,6 +57,7 @@ describe('context/App.tsx', () => {
5657
markNotificationDone: markNotificationDoneMock,
5758
unsubscribeNotification: unsubscribeNotificationMock,
5859
markRepoNotifications: markRepoNotificationsMock,
60+
markRepoNotificationsDone: markRepoNotificationsDoneMock,
5961
});
6062
});
6163

@@ -234,6 +236,40 @@ describe('context/App.tsx', () => {
234236
);
235237
});
236238

239+
it('should call markRepoNotificationsDone', async () => {
240+
const TestComponent = () => {
241+
const { markRepoNotificationsDone } = useContext(AppContext);
242+
243+
return (
244+
<button
245+
type="button"
246+
onClick={() =>
247+
markRepoNotificationsDone(
248+
'gitify-app/notifications-test',
249+
'github.com',
250+
)
251+
}
252+
>
253+
Test Case
254+
</button>
255+
);
256+
};
257+
258+
const { getByText } = customRender(<TestComponent />);
259+
260+
markRepoNotificationsDoneMock.mockReset();
261+
262+
fireEvent.click(getByText('Test Case'));
263+
264+
expect(markRepoNotificationsDoneMock).toHaveBeenCalledTimes(1);
265+
expect(markRepoNotificationsDoneMock).toHaveBeenCalledWith(
266+
{ enterpriseAccounts: [], token: null, user: null },
267+
mockSettings,
268+
'gitify-app/notifications-test',
269+
'github.com',
270+
);
271+
});
272+
237273
it('should call validateToken', async () => {
238274
apiRequestAuthMock.mockResolvedValueOnce(null);
239275

0 commit comments

Comments
 (0)