-
-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathtest.is_electron_renderer.js
85 lines (62 loc) · 1.84 KB
/
test.is_electron_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
'use strict';
// MODULES //
var tape = require( 'tape' );
var proxyquire = require( 'proxyquire' );
var ENV = require( '@stdlib/utils/env' );
var isElectronRenderer = require( './../lib/is_electron_renderer.js' );
// FIXTURES //
function Process() {
this.type = 'renderer';
this.versions = {
'electron': '1.0.0',
'chrome': '42.1.34'
};
this.env = ENV;
return this;
}
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof isElectronRenderer, 'function', 'main export is a function' );
t.end();
});
tape( 'the function returns `true` if runtime is the Electron renderer process', function test( t ) {
var isElectronRenderer;
var proc;
var bool;
proc = new Process();
isElectronRenderer = proxyquire( './../lib/is_electron_renderer.js', {
'@stdlib/assert/is-electron': true,
'./process.js': proc
});
bool = isElectronRenderer();
t.strictEqual( bool, true, 'returns true' );
t.end();
});
tape( 'the function returns `false` if runtime is not the Electron renderer process (not Electron)', function test( t ) {
var isElectronRenderer;
var proc;
var bool;
proc = new Process();
isElectronRenderer = proxyquire( './../lib/is_electron_renderer.js', {
'@stdlib/assert/is-electron': false,
'./process.js': proc
});
bool = isElectronRenderer();
t.strictEqual( bool, false, 'returns false' );
t.end();
});
tape( 'the function returns `false` if runtime is not the Electron renderer process (process type does not equal `renderer`)', function test( t ) {
var isElectronRenderer;
var proc;
var bool;
proc = new Process();
proc.type = 'browser';
isElectronRenderer = proxyquire( './../lib/is_electron_renderer.js', {
'@stdlib/assert/is-electron': true,
'./process.js': proc
});
bool = isElectronRenderer();
t.strictEqual( bool, false, 'returns false' );
t.end();
});