forked from internxt/drive-desktop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjest.setup.renderer.js
99 lines (84 loc) · 1.95 KB
/
jest.setup.renderer.js
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
/* eslint-disable */
require('@testing-library/jest-dom');
global.window = global.window || {};
global.window.electron = {
antivirus: {
onScanProgress: jest.fn(),
removeScanProgressListener: jest.fn(),
isAvailable: jest.fn(),
addItemsToScan: jest.fn(),
scanItems: jest.fn(),
removeInfectedFiles: jest.fn(),
cancelScan: jest.fn(),
},
ipc: {
invoke: jest.fn(),
on: jest.fn(),
removeListener: jest.fn(),
},
dialog: {
showOpenDialog: jest.fn(),
showSaveDialog: jest.fn(),
},
shell: {
openExternal: jest.fn(),
},
};
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key) => key,
i18n: {
changeLanguage: jest.fn(),
},
}),
}));
// Mock @headlessui/react components
jest.mock('@headlessui/react', () => {
const React = require('react');
const Dialog = function (props) {
return props.children;
};
Dialog.Overlay = function (props) {
return React.createElement('div', {
className: props.className,
'data-testid': 'dialog-overlay',
});
};
Dialog.Title = function (props) {
return React.createElement('div', props, props.children);
};
const Transition = function (props) {
return props.show !== false ? props.children : null;
};
Transition.Child = function (props) {
return props.children;
};
const Menu = function (props) {
return React.createElement(
props.as || 'div',
{ className: props.className },
props.children
);
};
Menu.Button = function (props) {
return React.createElement('div', props, props.children);
};
Menu.Items = function (props) {
return React.createElement('div', props, props.children);
};
Menu.Item = function (props) {
return props.children({ active: false });
};
const Fragment = function (props) {
return props.children;
};
return {
Dialog,
Transition,
Menu,
Fragment,
};
});
afterEach(() => {
jest.clearAllMocks();
});