diff --git a/src/renderer/components/notifications/NotificationTitle.test.tsx b/src/renderer/components/notifications/NotificationTitle.test.tsx index 29165a964..26b9f1a92 100644 --- a/src/renderer/components/notifications/NotificationTitle.test.tsx +++ b/src/renderer/components/notifications/NotificationTitle.test.tsx @@ -4,36 +4,17 @@ import { mockSettings } from '../../__mocks__/state-mocks'; import { NotificationTitle } from './NotificationTitle'; describe('renderer/components/notifications/NotificationTitle.tsx', () => { - it('should render plain text without code blocks', () => { - const tree = renderWithProviders(); - - expect(tree.container).toMatchSnapshot(); - }); - - it('should render text with single inline code block', () => { - const tree = renderWithProviders( - , - ); - - expect(tree.container).toMatchSnapshot(); - }); - - it('should render text with multiple inline code blocks', () => { - const tree = renderWithProviders( - , - ); - - expect(tree.container).toMatchSnapshot(); - }); - - it('should render text with code block at the start', () => { - const tree = renderWithProviders(); - - expect(tree.container).toMatchSnapshot(); - }); - - it('should render text with code block at the end', () => { - const tree = renderWithProviders(); + it.each([ + ['should render plain text without code blocks', 'Simple notification title'], + [ + 'should render text with single inline code block', + 'refactor: migrate deprecated atlaskit `xcss`', + ], + ['should render text with multiple inline code blocks', 'Replace `foo` with `bar` in config'], + ['should render text with code block at the start', '`useState` hook implementation'], + ['should render text with code block at the end', 'Fix issue with `render`'], + ])('%s', (_name, title) => { + const tree = renderWithProviders(); expect(tree.container).toMatchSnapshot(); }); diff --git a/src/renderer/components/settings/SystemSettings.test.tsx b/src/renderer/components/settings/SystemSettings.test.tsx index e9f483c63..83eb356ab 100644 --- a/src/renderer/components/settings/SystemSettings.test.tsx +++ b/src/renderer/components/settings/SystemSettings.test.tsx @@ -34,6 +34,7 @@ describe('renderer/components/settings/SystemSettings.tsx', () => { ['checkbox-keyboardShortcut', 'keyboardShortcut'], ['checkbox-showNotifications', 'showNotifications'], ['checkbox-showUpdateNotifications', 'showUpdateNotifications'], + ['checkbox-playSound', 'playSound'], ['checkbox-openAtStartup', 'openAtStartup'], ['checkbox-keepWindowOnBlur', 'keepWindowOnBlur'], ] as const)('should toggle %s checkbox', async (testId, setting) => { @@ -211,27 +212,7 @@ describe('renderer/components/settings/SystemSettings.tsx', () => { }); }); - it('should toggle the showNotifications checkbox', async () => { - await act(async () => { - renderWithProviders(); - }); - - await userEvent.click(screen.getByTestId('checkbox-showNotifications')); - - expect(toggleSettingSpy).toHaveBeenCalledTimes(1); - expect(toggleSettingSpy).toHaveBeenCalledWith('showNotifications'); - }); - describe('playSound', () => { - it('should toggle the playSound checkbox', async () => { - renderWithProviders(); - - await userEvent.click(screen.getByTestId('checkbox-playSound')); - - expect(toggleSettingSpy).toHaveBeenCalledTimes(1); - expect(toggleSettingSpy).toHaveBeenCalledWith('playSound'); - }); - it('volume controls should not be shown if playSound checkbox is false', async () => { renderWithProviders(, { settings: { ...mockSettings, playSound: false }, @@ -277,26 +258,4 @@ describe('renderer/components/settings/SystemSettings.tsx', () => { expect(updateSettingSpy).toHaveBeenCalledWith('notificationVolume', 20); }); }); - - it('should toggle the openAtStartup checkbox', async () => { - await act(async () => { - renderWithProviders(); - }); - - await userEvent.click(screen.getByTestId('checkbox-openAtStartup')); - - expect(toggleSettingSpy).toHaveBeenCalledTimes(1); - expect(toggleSettingSpy).toHaveBeenCalledWith('openAtStartup'); - }); - - it('should toggle the keepWindowOnBlur checkbox', async () => { - await act(async () => { - renderWithProviders(); - }); - - await userEvent.click(screen.getByTestId('checkbox-keepWindowOnBlur')); - - expect(toggleSettingSpy).toHaveBeenCalledTimes(1); - expect(toggleSettingSpy).toHaveBeenCalledWith('keepWindowOnBlur'); - }); }); diff --git a/src/renderer/routes/Login.test.tsx b/src/renderer/routes/Login.test.tsx index 8799a0494..f907c2747 100644 --- a/src/renderer/routes/Login.test.tsx +++ b/src/renderer/routes/Login.test.tsx @@ -28,31 +28,17 @@ describe('renderer/routes/Login.tsx', () => { expect(navigateMock).toHaveBeenCalledWith('/', { replace: true }); }); - it('should login with github', async () => { + it.each([ + ['login-github', '/login/github/device-flow'], + ['login-pat', '/login/github/personal-access-token'], + ['login-oauth-app', '/login/github/oauth-app'], + ])('navigates %s', async (testId, route) => { renderWithProviders(); - await userEvent.click(screen.getByTestId('login-github')); + await userEvent.click(screen.getByTestId(testId)); expect(navigateMock).toHaveBeenCalledTimes(1); - expect(navigateMock).toHaveBeenCalledWith('/login/github/device-flow'); - }); - - it('should navigate to login with personal access token', async () => { - renderWithProviders(); - - await userEvent.click(screen.getByTestId('login-pat')); - - expect(navigateMock).toHaveBeenCalledTimes(1); - expect(navigateMock).toHaveBeenCalledWith('/login/github/personal-access-token'); - }); - - it('should navigate to login with oauth app', async () => { - renderWithProviders(); - - await userEvent.click(screen.getByTestId('login-oauth-app')); - - expect(navigateMock).toHaveBeenCalledTimes(1); - expect(navigateMock).toHaveBeenCalledWith('/login/github/oauth-app'); + expect(navigateMock).toHaveBeenCalledWith(route); }); it('should navigate to login with Gitea personal access token', async () => { diff --git a/src/renderer/utils/forges/github/handlers/checkSuite.test.ts b/src/renderer/utils/forges/github/handlers/checkSuite.test.ts index 6f1d2b965..559a8070b 100644 --- a/src/renderer/utils/forges/github/handlers/checkSuite.test.ts +++ b/src/renderer/utils/forges/github/handlers/checkSuite.test.ts @@ -23,41 +23,19 @@ describe('renderer/utils/notifications/handlers/checkSuite.ts', () => { }); }); - it('failed check suite state', async () => { - const mockNotification = mockPartialGitifyNotification({ - title: 'Demo workflow run failed for main branch', - type: 'CheckSuite', - }); - - const result = await checkSuiteHandler.enrich(mockNotification); - - expect(result).toEqual({ - state: 'FAILURE', - user: undefined, - htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain', - }); - }); - - it('failed at startup check suite state', async () => { + it.each([ + ['failed check suite state', 'Demo workflow run failed for main branch'], + [ + 'failed at startup check suite state', + 'Demo workflow run failed at startup for main branch', + ], + [ + 'multiple attempts failed check suite state', + 'Demo workflow run, Attempt #3 failed for main branch', + ], + ])('%s', async (_name, title) => { const mockNotification = mockPartialGitifyNotification({ - title: 'Demo workflow run failed at startup for main branch', - type: 'CheckSuite', - }); - - const result = await checkSuiteHandler.enrich(mockNotification); - - expect(result).toEqual({ - state: 'FAILURE', - user: undefined, - htmlUrl: - 'https://github.com/gitify-app/notifications-test/actions?query=workflow%3A%22Demo%22+is%3Afailure+branch%3Amain', - }); - }); - - it('multiple attempts failed check suite state', async () => { - const mockNotification = mockPartialGitifyNotification({ - title: 'Demo workflow run, Attempt #3 failed for main branch', + title, type: 'CheckSuite', });