-
-
Notifications
You must be signed in to change notification settings - Fork 805
/
Copy pathtest.js
49 lines (38 loc) · 1.06 KB
/
test.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
'use strict';
// MODULES //
var tape = require( 'tape' );
var detect = require( './../lib' );
// VARIABLES //
var hasSymbols = ( typeof Symbol === 'function' );
// TESTS //
tape( 'main export is a function', function test( t ) {
t.ok( true, __filename );
t.equal( typeof detect, 'function', 'main export is a function' );
t.end();
});
tape( 'feature detection result is a boolean', function test( t ) {
t.equal( typeof detect(), 'boolean', 'detection result is a boolean' );
t.end();
});
tape( 'if `Symbols` are supported, detection result is `true`', function test( t ) {
if ( hasSymbols ) {
t.equal( detect(), true, 'detection result is `true`' );
} else {
t.equal( detect(), false, 'detection result is `false`' );
}
t.end();
});
tape( 'the function guards against a `Symbol` global variable which does not produce `symbols`', function test( t ) {
var tmp;
if ( hasSymbols ) {
tmp = Symbol;
Symbol = {};
} else {
global.Symbol = {};
}
t.equal( detect(), false, 'detection result is `false`' );
if ( hasSymbols ) {
Symbol = tmp;
}
t.end();
});