From 33b1d05a569e30a0e641791850d8d879c348342b Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 29 May 2024 08:06:23 -0400 Subject: [PATCH] test: markRepoNotificationsDone --- src/context/App.test.tsx | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/context/App.test.tsx b/src/context/App.test.tsx index 0409a4e79..5ba772d4c 100644 --- a/src/context/App.test.tsx +++ b/src/context/App.test.tsx @@ -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({ @@ -56,6 +57,7 @@ describe('context/App.tsx', () => { markNotificationDone: markNotificationDoneMock, unsubscribeNotification: unsubscribeNotificationMock, markRepoNotifications: markRepoNotificationsMock, + markRepoNotificationsDone: markRepoNotificationsDoneMock, }); }); @@ -234,6 +236,40 @@ describe('context/App.tsx', () => { ); }); + it('should call markRepoNotificationsDone', async () => { + const TestComponent = () => { + const { markRepoNotificationsDone } = useContext(AppContext); + + return ( + + ); + }; + + const { getByText } = customRender(); + + 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);