-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvitest.setup.ts
More file actions
101 lines (87 loc) · 2.05 KB
/
vitest.setup.ts
File metadata and controls
101 lines (87 loc) · 2.05 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import '@testing-library/jest-dom'
import React from 'react'
import { vi } from 'vitest'
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {},
removeListener: () => {},
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => false
})
})
class ResizeObserverMock {
observe() {}
unobserve() {}
disconnect() {}
}
window.ResizeObserver = ResizeObserverMock
vi.mock('@tauri-apps/api/core', () => ({
invoke: vi.fn()
}))
vi.mock('@tauri-apps/api/event', () => ({
listen: vi.fn()
}))
vi.mock('@tauri-apps/plugin-fs', () => ({
readDir: vi.fn(),
readTextFile: vi.fn(),
writeTextFile: vi.fn(),
mkdir: vi.fn(),
remove: vi.fn(),
rename: vi.fn(),
stat: vi.fn(),
watchImmediate: vi.fn()
}))
vi.mock('@tauri-apps/plugin-dialog', () => ({
open: vi.fn(),
save: vi.fn(),
message: vi.fn(),
confirm: vi.fn()
}))
vi.mock('@tauri-apps/plugin-clipboard-manager', () => ({
readText: vi.fn(),
writeText: vi.fn()
}))
vi.mock('@tauri-apps/plugin-store', () => ({
createStore: vi.fn()
}))
vi.mock('@tauri-apps/plugin-os', () => ({
platform: vi.fn(),
version: vi.fn(),
type: vi.fn(),
arch: vi.fn(),
tempdir: vi.fn(),
homedir: vi.fn()
}))
vi.mock('react-virtuoso', () => {
const VirtuosoComponent = React.forwardRef(
(
{
data,
itemContent
}: {
data: unknown[]
itemContent: (index: number, item: unknown) => React.JSX.Element
},
_ref: React.Ref<unknown>
) => {
return React.createElement(
'div',
{ 'data-testid': 'virtuoso-scroller', 'data-virtuoso-scroller': 'true' },
React.createElement(
'div',
{ 'data-testid': 'virtuoso-item-list' },
data.map((item, index) =>
React.createElement('div', { key: index }, itemContent(index, item))
)
)
)
}
)
VirtuosoComponent.displayName = 'Virtuoso'
return { Virtuoso: VirtuosoComponent }
})