Skip to content
Merged
Show file tree
Hide file tree
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
104 changes: 13 additions & 91 deletions src/renderer/components/settings/NotificationSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,59 +124,25 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
});
});

it('should toggle the fetchAllNotifications checkbox', async () => {
it.each([
['checkbox-fetchAllNotifications', 'fetchAllNotifications'],
['checkbox-detailedNotifications', 'detailedNotifications'],
['checkbox-showPills', 'showPills'],
['checkbox-showNumber', 'showNumber'],
['checkbox-showOnlyParticipating', 'participating'],
['checkbox-fetchReadNotifications', 'fetchReadNotifications'],
['checkbox-markAsDoneOnOpen', 'markAsDoneOnOpen'],
['checkbox-markAsDoneOnUnsubscribe', 'markAsDoneOnUnsubscribe'],
['checkbox-delayNotificationState', 'delayNotificationState'],
] as const)('should toggle %s checkbox', async (testId, setting) => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-fetchAllNotifications'));
await userEvent.click(screen.getByTestId(testId));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('fetchAllNotifications');
});

it('should toggle detailed notifications checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-detailedNotifications'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('detailedNotifications');
});

it('should toggle metric pills checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-showPills'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('showPills');
});

it('should toggle show number checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-showNumber'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('showNumber');
});

it('should toggle the showOnlyParticipating checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-showOnlyParticipating'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('participating');
expect(toggleSettingSpy).toHaveBeenCalledWith(setting);
});

it('should open official docs for showOnlyParticipating tooltip', async () => {
Expand All @@ -198,48 +164,4 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
'https://docs.github.com/en/account-and-profile/managing-subscriptions-and-notifications-on-github/setting-up-notifications/configuring-notifications#about-participating-and-watching-notifications',
);
});

it('should toggle the fetchReadNotifications checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-fetchReadNotifications'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('fetchReadNotifications');
});

it('should toggle the markAsDoneOnOpen checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-markAsDoneOnOpen'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('markAsDoneOnOpen');
});

it('should toggle the markAsDoneOnUnsubscribe checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-markAsDoneOnUnsubscribe'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('markAsDoneOnUnsubscribe');
});

it('should toggle the delayNotificationState checkbox', async () => {
await act(async () => {
renderWithProviders(<NotificationSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-delayNotificationState'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('delayNotificationState');
});
});
11 changes: 8 additions & 3 deletions src/renderer/components/settings/SystemSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ describe('renderer/components/settings/SystemSettings.tsx', () => {
expect(updateSettingSpy).toHaveBeenCalledWith('openLinks', 'BACKGROUND');
});

it('should toggle the keyboardShortcut checkbox', async () => {
it.each([
['checkbox-keyboardShortcut', 'keyboardShortcut'],
['checkbox-showNotifications', 'showNotifications'],
['checkbox-openAtStartup', 'openAtStartup'],
['checkbox-keepWindowOnBlur', 'keepWindowOnBlur'],
] as const)('should toggle %s checkbox', async (testId, setting) => {
await act(async () => {
renderWithProviders(<SystemSettings />);
});

await userEvent.click(screen.getByTestId('checkbox-keyboardShortcut'));
await userEvent.click(screen.getByTestId(testId));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('keyboardShortcut');
expect(toggleSettingSpy).toHaveBeenCalledWith(setting);
});

it('should reset global shortcut to default when customized', async () => {
Expand Down
24 changes: 7 additions & 17 deletions src/renderer/components/settings/TraySettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,14 @@ describe('renderer/components/settings/TraySettings.tsx', () => {
});
});

it('should toggle the showNotificationsCountInTray checkbox', async () => {
await userEvent.click(screen.getByTestId('checkbox-showNotificationsCountInTray'));
it.each([
['checkbox-showNotificationsCountInTray', 'showNotificationsCountInTray'],
['checkbox-useUnreadActiveIcon', 'useUnreadActiveIcon'],
['checkbox-useAlternateIdleIcon', 'useAlternateIdleIcon'],
] as const)('should toggle %s checkbox', async (testId, setting) => {
await userEvent.click(screen.getByTestId(testId));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('showNotificationsCountInTray');
});

it('should toggle the useUnreadActiveIcon checkbox', async () => {
await userEvent.click(screen.getByTestId('checkbox-useUnreadActiveIcon'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('useUnreadActiveIcon');
});

it('should toggle the useAlternateIdleIcon checkbox', async () => {
await userEvent.click(screen.getByTestId('checkbox-useAlternateIdleIcon'));

expect(toggleSettingSpy).toHaveBeenCalledTimes(1);
expect(toggleSettingSpy).toHaveBeenCalledWith('useAlternateIdleIcon');
expect(toggleSettingSpy).toHaveBeenCalledWith(setting);
});
});