Skip to content

Commit 82085f1

Browse files
authored
test: improve native test (#2391)
Signed-off-by: Adam Setch <[email protected]>
1 parent 15f40e9 commit 82085f1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ import {
44
mockAccountNotifications,
55
mockSingleAccountNotifications,
66
} from '../../__mocks__/notifications-mocks';
7+
import * as helpers from '../helpers';
78
import * as native from './native';
89

910
describe('renderer/utils/notifications/native.ts', () => {
11+
const mockHtmlUrl =
12+
mockSingleAccountNotifications[0].notifications[0].repository.html_url;
13+
14+
jest
15+
.spyOn(helpers, 'generateGitHubWebUrl')
16+
.mockImplementation(async () => mockHtmlUrl);
17+
1018
afterEach(() => {
1119
jest.clearAllMocks();
1220
});
@@ -28,10 +36,9 @@ describe('renderer/utils/notifications/native.ts', () => {
2836
expect.stringContaining(
2937
mockSingleAccountNotifications[0].notifications[0].subject.title,
3038
),
31-
expect.stringContaining(
32-
mockSingleAccountNotifications[0].notifications[0].repository.html_url,
33-
),
39+
expect.stringContaining(mockHtmlUrl),
3440
);
41+
expect(helpers.generateGitHubWebUrl).toHaveBeenCalledTimes(1);
3542
});
3643

3744
it('should raise a native notification for multiple new notifications', async () => {
@@ -46,5 +53,6 @@ describe('renderer/utils/notifications/native.ts', () => {
4653
'You have 2 notifications',
4754
null,
4855
);
56+
expect(helpers.generateGitHubWebUrl).toHaveBeenCalledTimes(0);
4957
});
5058
});

0 commit comments

Comments
 (0)