forked from TypeCellOS/BlockNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitestSetup.ts
More file actions
50 lines (45 loc) · 1.02 KB
/
vitestSetup.ts
File metadata and controls
50 lines (45 loc) · 1.02 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
import { afterEach, beforeEach } from "vitest";
beforeEach(() => {
(window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS = {};
});
afterEach(() => {
delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS;
});
// Mock ClipboardEvent
class ClipboardEventMock extends Event {
public clipboardData = {
getData: () => {
//
},
setData: () => {
//
},
};
}
(global as any).ClipboardEvent = ClipboardEventMock;
// Mock DragEvent
class DragEventMock extends Event {
public dataTransfer = {
getData: () => {
//
},
setData: () => {
//
},
};
}
(global as any).DragEvent = DragEventMock;
// Mock matchMedia for Mantine
Object.defineProperty(window, "matchMedia", {
writable: true,
value: (query: string) => ({
matches: false,
media: query,
onchange: null,
addListener: () => {}, // deprecated
removeListener: () => {}, // deprecated
addEventListener: () => {},
removeEventListener: () => {},
dispatchEvent: () => {},
}),
});