Skip to content

test: markRepoNotificationsDone #1155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
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