-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathtray.test.ts
More file actions
56 lines (44 loc) · 1.98 KB
/
tray.test.ts
File metadata and controls
56 lines (44 loc) · 1.98 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
// @vitest-environment happy-dom
import { mockSettings } from '../../__mocks__/state-mocks';
import type { SettingsState } from '../../types';
import * as comms from './comms';
import { setTrayIconColorAndTitle } from './tray';
describe('renderer/utils/tray.ts', () => {
const updateTrayColorSpy = vi.spyOn(comms, 'updateTrayColor');
const updateTrayTitleSpy = vi.spyOn(comms, 'updateTrayTitle');
describe('setTrayIconColorAndTitle', () => {
it('should update tray color and title when showNotificationsCountInTray is true and has unread notifications', () => {
const settings: SettingsState = {
...mockSettings,
showNotificationsCountInTray: true,
};
setTrayIconColorAndTitle(5, settings);
expect(updateTrayColorSpy).toHaveBeenCalledTimes(1);
expect(updateTrayColorSpy).toHaveBeenCalledWith(5);
expect(updateTrayTitleSpy).toHaveBeenCalledTimes(1);
expect(updateTrayTitleSpy).toHaveBeenCalledWith('5');
});
it('should update tray color and empty title when showNotificationsCountInTray is false and has unread notifications', () => {
const settings: SettingsState = {
...mockSettings,
showNotificationsCountInTray: false,
};
setTrayIconColorAndTitle(5, settings);
expect(updateTrayColorSpy).toHaveBeenCalledTimes(1);
expect(updateTrayColorSpy).toHaveBeenCalledWith(5);
expect(updateTrayTitleSpy).toHaveBeenCalledTimes(1);
expect(updateTrayTitleSpy).toHaveBeenCalledWith('');
});
it('should update tray with empty title when no unread notifications', () => {
const settings: SettingsState = {
...mockSettings,
showNotificationsCountInTray: true,
};
setTrayIconColorAndTitle(0, settings);
expect(updateTrayColorSpy).toHaveBeenCalledTimes(1);
expect(updateTrayColorSpy).toHaveBeenCalledWith(0);
expect(updateTrayTitleSpy).toHaveBeenCalledTimes(1);
expect(updateTrayTitleSpy).toHaveBeenCalledWith('');
});
});
});