-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetupTests.ts
More file actions
37 lines (35 loc) · 1.06 KB
/
Copy pathsetupTests.ts
File metadata and controls
37 lines (35 loc) · 1.06 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
import '@testing-library/jest-dom'
// Mock matchMedia which is not present in jsdom but might be needed by some UI components
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {}, // deprecated
removeListener: () => {}, // deprecated
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false,
}),
})
// Mock electronAPI for testing environments
if (!window.electronAPI) {
window.electronAPI = {
getNotes: async () => [],
saveNote: async () => true,
deleteNote: async () => true,
renameNote: async () => true,
openSettings: () => {},
closeWindow: () => {},
quitApp: () => {},
setLaunchAtStartup: () => {},
updateGlobalShortcut: () => {},
readNote: async () => '',
exportNote: async () => true,
openExternal: () => {},
openFile: () => {},
safeStorageEncrypt: async (val: string) => val,
safeStorageDecrypt: async (val: string) => val,
} as any
}