-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathnative.test.ts
More file actions
57 lines (47 loc) · 1.73 KB
/
native.test.ts
File metadata and controls
57 lines (47 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// @vitest-environment happy-dom
import { waitFor } from '@testing-library/react';
import {
mockMultipleAccountNotifications,
mockSingleAccountNotifications,
} from '../../__mocks__/notifications-mocks';
import * as url from '../notifications/url';
import * as native from './native';
describe('renderer/utils/system/native.ts', () => {
const mockHtmlUrl =
mockSingleAccountNotifications[0].notifications[0].repository.htmlUrl;
vi.spyOn(url, 'generateGitHubWebUrl').mockImplementation(
async () => mockHtmlUrl,
);
it('should raise a native notification for a single new notification', async () => {
native.raiseNativeNotification(
mockSingleAccountNotifications[0].notifications,
);
await waitFor(() =>
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
);
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
expect.stringContaining(
mockSingleAccountNotifications[0].notifications[0].repository.fullName,
),
expect.stringContaining(
mockSingleAccountNotifications[0].notifications[0].subject.title,
),
expect.stringContaining(mockHtmlUrl),
);
expect(url.generateGitHubWebUrl).toHaveBeenCalledTimes(1);
});
it('should raise a native notification for multiple new notifications', async () => {
native.raiseNativeNotification(
mockMultipleAccountNotifications[0].notifications,
);
await waitFor(() =>
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledTimes(1),
);
expect(window.gitify.raiseNativeNotification).toHaveBeenCalledWith(
'Gitify',
'You have 2 notifications',
null,
);
expect(url.generateGitHubWebUrl).toHaveBeenCalledTimes(0);
});
});