insomnia/packages/insomnia-app/app/__mocks__/electron.js

58 lines
972 B
JavaScript
Raw Normal View History

import mkdirp from 'mkdirp';
import events from 'events';
2018-06-25 17:42:50 +00:00
const RANDOM_STRING = Math.random()
.toString()
.replace('.', '');
const remote = {
app: {
2018-06-25 17:42:50 +00:00
getPath(name) {
const dir = `/tmp/insomnia-tests-${RANDOM_STRING}/${name}`;
mkdirp.sync(dir);
return dir;
},
2018-06-25 17:42:50 +00:00
getLocale() {
return 'en-US';
},
},
net: {
2018-06-25 17:42:50 +00:00
request(url) {
const req = new events.EventEmitter();
2018-06-25 17:42:50 +00:00
req.end = function() {};
return req;
},
},
BrowserWindow: {
2018-06-25 17:42:50 +00:00
getAllWindows() {
return [];
},
2018-06-25 17:42:50 +00:00
getFocusedWindow() {
return {
2018-06-25 17:42:50 +00:00
getContentBounds() {
return { width: 1900, height: 1060 };
},
};
},
},
screen: {
2018-06-25 17:42:50 +00:00
getPrimaryDisplay() {
return { workAreaSize: { width: 1920, height: 1080 } };
},
},
};
module.exports = {
...remote,
remote: remote,
ipcMain: {
2018-06-25 17:42:50 +00:00
on() {},
once() {},
2016-11-23 23:42:10 +00:00
},
ipcRenderer: {
2018-06-25 17:42:50 +00:00
on() {},
once() {},
send() {},
},
};