1 | 'use strict';
|
2 |
|
3 | var isPrimitive = require('../src/primitive'),
|
4 | assert = require('chai').assert;
|
5 |
|
6 | describe('primitive', function() {
|
7 | it('checks whether value is a primitive string', function() {
|
8 | assert.ok(isPrimitive('string'));
|
9 |
|
10 | assert.ok(!isPrimitive(new String('string')));
|
11 | });
|
12 |
|
13 | it('checks whether value is a primitive number', function() {
|
14 | assert.ok(isPrimitive(100));
|
15 | assert.ok(isPrimitive(NaN));
|
16 |
|
17 | assert.ok(!isPrimitive(new Number(100)));
|
18 | });
|
19 |
|
20 | it('checks whether value is a primitive boolean', function() {
|
21 | assert.ok(isPrimitive(true));
|
22 | assert.ok(isPrimitive(false));
|
23 |
|
24 | assert.ok(!isPrimitive(new Boolean(true)));
|
25 | assert.ok(!isPrimitive(new Boolean(false)));
|
26 | });
|
27 |
|
28 | it('checks whether value is null', function() {
|
29 | assert.ok(isPrimitive(null));
|
30 | });
|
31 |
|
32 | it('checks whether value is undefined', function() {
|
33 | assert.ok(isPrimitive(undefined));
|
34 | });
|
35 |
|
36 | it('return false for any other value', function() {
|
37 | assert.ok(!isPrimitive(/test/));
|
38 | assert.ok(!isPrimitive(Object.create(null)));
|
39 | assert.ok(!isPrimitive({}));
|
40 | });
|
41 | });
|