-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
44 lines (34 loc) · 1.08 KB
/
index.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
const test = require('tap').test;
const isElectron = require('../');
test('should return false in Node.js', function(t) {
const isElectron = require('../');
t.equal(isElectron(), false);
t.end();
});
test('Renderer process', function(t) {
const window = global.window;
global.window = {};
global.window.process = global.window.process || {};
global.window.process.type = 'renderer';
t.equal(isElectron(), true);
global.window = window;
t.equal(isElectron(), false);
t.end();
});
test('Main process', function(t) {
const electron = process.versions.electron;
process.versions.electron = 'x.y.z';
t.equal(isElectron(), true);
process.versions.electron = electron;
t.equal(isElectron(), false);
t.end();
});
test('Detect the user agent when the `nodeIntegration` option is set to true', function(t) {
const navigator = global.navigator;
global.navigator = {};
global.navigator.userAgent = 'Electron';
t.equal(isElectron(), true);
global.navigator = navigator;
t.equal(isElectron(), false);
t.end();
});