-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve an issue when the nodeIntegration option is set to false (closes
#1)
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,44 @@ | ||
var test = require('tap').test; | ||
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(); | ||
}); |