-
Notifications
You must be signed in to change notification settings - Fork 272
/
Copy pathelectron.js
58 lines (51 loc) · 1.07 KB
/
electron.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
const { namespacedEvent } = require('../../shared/events');
// @ts-ignore
window.Notification = function (title) {
this.title = title;
return {
onclick: jest.fn(),
};
};
// @ts-ignore
window.Audio = class Audio {
constructor(path) {
this.path = path;
}
play() {}
};
// @ts-ignore
window.localStorage = {
store: {},
getItem: function (key) {
return this.store[key];
},
setItem: function (key, item) {
this.store[key] = item;
},
removeItem: jest.fn(),
};
window.alert = jest.fn();
module.exports = {
ipcRenderer: {
send: jest.fn(),
on: jest.fn(),
sendSync: jest.fn(),
invoke: jest.fn((channel, ..._args) => {
switch (channel) {
case 'get-platform':
return Promise.resolve('darwin');
case namespacedEvent('version'):
return Promise.resolve('0.0.1');
default:
return Promise.reject(new Error(`Unknown channel: ${channel}`));
}
}),
},
shell: {
openExternal: jest.fn(),
},
webFrame: {
setZoomLevel: jest.fn(),
getZoomLevel: jest.fn(),
},
};