-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.js
44 lines (40 loc) · 1.18 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
/*!
* is-primitive <https://github.com/jonschlinkert/is-primitive>
*
* Copyright (c) 2014-2019, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
require('mocha');
const assert = require('assert');
const isPrimitive = require('./');
describe('isPrimitive', function() {
it('should return true when primitive value', function() {
assert(isPrimitive());
assert(isPrimitive(undefined));
assert(isPrimitive(null));
assert(isPrimitive(0));
assert(isPrimitive(1));
assert(isPrimitive('foo'));
assert(isPrimitive(true));
assert(isPrimitive(false));
assert(isPrimitive(NaN));
assert(isPrimitive(Infinity));
if (typeof Symbol !== 'undefined') {
assert(isPrimitive(Symbol()));
}
if (typeof BigInt !== 'undefined') {
assert(isPrimitive(BigInt(0)));
}
});
it('should return false when not primitive value', function() {
assert(!isPrimitive({}));
assert(!isPrimitive([]));
assert(!isPrimitive(/./));
assert(!isPrimitive(function() {}));
assert(!isPrimitive(new Date()));
assert(!isPrimitive(new Number()));
assert(!isPrimitive(new String()));
assert(!isPrimitive(new Boolean()));
});
});