Skip to content

Commit 97d8cf5

Browse files
committed
refactor: native test
Signed-off-by: Adam Setch <[email protected]>
1 parent 572f887 commit 97d8cf5

File tree

1 file changed

+35
-39
lines changed

1 file changed

+35
-39
lines changed

src/renderer/utils/notifications/native.test.ts

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,40 @@ describe('renderer/utils/notifications/native.ts', () => {
1111
jest.clearAllMocks();
1212
});
1313

14-
describe('triggerNativeNotifications', () => {
15-
it('should raise a native notification for a single new notification', async () => {
16-
native.raiseNativeNotification(
17-
mockSingleAccountNotifications[0].notifications,
18-
);
19-
20-
// wait for async native handling (generateGitHubWebUrl) to complete
21-
await waitFor(() =>
22-
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
23-
);
24-
25-
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
26-
expect.stringContaining(
27-
mockSingleAccountNotifications[0].notifications[0].repository
28-
.full_name,
29-
),
30-
expect.stringContaining(
31-
mockSingleAccountNotifications[0].notifications[0].subject.title,
32-
),
33-
expect.stringContaining(
34-
mockSingleAccountNotifications[0].notifications[0].repository
35-
.html_url,
36-
),
37-
);
38-
});
39-
40-
it('should raise a native notification for multiple new notifications', async () => {
41-
native.raiseNativeNotification(mockAccountNotifications[0].notifications);
42-
43-
await waitFor(() =>
44-
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
45-
);
46-
47-
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
48-
'Gitify',
49-
'You have 2 notifications',
50-
null,
51-
);
52-
});
14+
it('should raise a native notification for a single new notification', async () => {
15+
native.raiseNativeNotification(
16+
mockSingleAccountNotifications[0].notifications,
17+
);
18+
19+
// wait for async native handling (generateGitHubWebUrl) to complete
20+
await waitFor(() =>
21+
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
22+
);
23+
24+
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
25+
expect.stringContaining(
26+
mockSingleAccountNotifications[0].notifications[0].repository.full_name,
27+
),
28+
expect.stringContaining(
29+
mockSingleAccountNotifications[0].notifications[0].subject.title,
30+
),
31+
expect.stringContaining(
32+
mockSingleAccountNotifications[0].notifications[0].repository.html_url,
33+
),
34+
);
35+
});
36+
37+
it('should raise a native notification for multiple new notifications', async () => {
38+
native.raiseNativeNotification(mockAccountNotifications[0].notifications);
39+
40+
await waitFor(() =>
41+
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
42+
);
43+
44+
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
45+
'Gitify',
46+
'You have 2 notifications',
47+
null,
48+
);
5349
});
5450
});

0 commit comments

Comments
 (0)