UNPKG

1.72 kBJavaScriptView Raw
1// test types utils
2var assert = require('assert'),
3 approx = require('../../tools/approx'),
4 types = require('../../lib/utils/types');
5
6describe ('types', function () {
7
8 it('should return the type of null', function () {
9 assert.equal(types.type(null), 'null');
10 });
11
12 it('should return the type of undefined', function () {
13 assert.equal(types.type(undefined), 'undefined');
14 assert.equal(types.type(), 'undefined');
15 });
16
17 it('should return the type of a boolean', function () {
18
19 assert.equal(types.type(false), 'boolean');
20 assert.equal(types.type(true), 'boolean');
21 });
22
23 it('should return the type of a number', function () {
24 assert.equal(types.type(2.3), 'number');
25 assert.equal(types.type(Number(2.3)), 'number');
26 assert.equal(types.type(new Number(2.3)), 'number');
27 assert.equal(types.type(NaN), 'number');
28 });
29
30 it('should return the type of a string', function () {
31 assert.equal(types.type('bla'), 'string');
32 assert.equal(types.type(new String('bla')), 'string');
33 });
34
35 it('should return the type of an object', function () {
36 assert.equal(types.type({}), 'Object');
37 assert.equal(types.type(new Object()), 'Object');
38 });
39
40 it('should return the type of an array', function () {
41 assert.equal(types.type([]), 'Array');
42 assert.equal(types.type(new Array()), 'Array');
43 });
44
45 it('should return the type of a function', function () {
46 assert.equal(types.type(function () {}), 'Function');
47 });
48
49 it('should return the type of a date', function () {
50 assert.equal(types.type(new Date()), 'Date');
51 });
52
53 it('should return the type of a regexp', function () {
54 assert.equal(types.type(/regexp/), 'RegExp');
55 });
56
57});
\No newline at end of file