-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
71 lines (64 loc) · 1.85 KB
/
vitest.setup.ts
File metadata and controls
71 lines (64 loc) · 1.85 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import '@testing-library/jest-dom/vitest';
import { useFiltersStore } from '../stores';
// Sets timezone to UTC for consistent date/time in tests and snapshots
process.env.TZ = 'UTC';
/**
* Reset stores
*/
beforeEach(() => {
useFiltersStore.getState().reset();
});
/**
* Gitify context bridge API
*/
window.gitify = {
app: {
version: vi.fn().mockResolvedValue('v0.0.1'),
hide: vi.fn(),
quit: vi.fn(),
show: vi.fn(),
},
twemojiDirectory: vi.fn().mockResolvedValue('/mock/images/assets'),
openExternalLink: vi.fn(),
decryptValue: vi.fn().mockResolvedValue('decrypted'),
encryptValue: vi.fn().mockResolvedValue('encrypted'),
platform: {
isLinux: vi.fn().mockReturnValue(false),
isMacOS: vi.fn().mockReturnValue(true),
isWindows: vi.fn().mockReturnValue(false),
},
zoom: {
getLevel: vi.fn(),
setLevel: vi.fn(),
},
tray: {
updateColor: vi.fn(),
updateTitle: vi.fn(),
useAlternateIdleIcon: vi.fn(),
useUnreadActiveIcon: vi.fn(),
},
notificationSoundPath: vi.fn(),
onAuthCallback: vi.fn(),
onResetApp: vi.fn(),
onSystemThemeUpdate: vi.fn(),
setAutoLaunch: vi.fn(),
setKeyboardShortcut: vi.fn(),
raiseNativeNotification: vi.fn(),
};
// Mock clipboard API
Object.defineProperty(navigator, 'clipboard', {
value: {
writeText: vi.fn().mockResolvedValue(undefined),
readText: vi.fn().mockResolvedValue(''),
},
configurable: true,
});
/**
* Primer React testing helpers
* Note: @primer/react/test-helpers uses Jest internally, so we provide our own mocks
* - https://primer.style/product/getting-started/react/#testing
* - https://github.com/primer/react/blob/main/packages/react/src/utils/test-helpers.tsx
*/
// Mock `showPopover` and `hidePopover` used by Primer React TooltipV2
global.HTMLElement.prototype.showPopover = vi.fn();
global.HTMLElement.prototype.hidePopover = vi.fn();