Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80538 views
1
var test = require('tape');
2
var equal = require('../');
3
var isArguments = require('../lib/is_arguments.js');
4
var objectKeys = require('../lib/keys.js');
5
6
test('equal', function (t) {
7
t.ok(equal(
8
{ a : [ 2, 3 ], b : [ 4 ] },
9
{ a : [ 2, 3 ], b : [ 4 ] }
10
));
11
t.end();
12
});
13
14
test('not equal', function (t) {
15
t.notOk(equal(
16
{ x : 5, y : [6] },
17
{ x : 5, y : 6 }
18
));
19
t.end();
20
});
21
22
test('nested nulls', function (t) {
23
t.ok(equal([ null, null, null ], [ null, null, null ]));
24
t.end();
25
});
26
27
test('strict equal', function (t) {
28
t.notOk(equal(
29
[ { a: 3 }, { b: 4 } ],
30
[ { a: '3' }, { b: '4' } ],
31
{ strict: true }
32
));
33
t.end();
34
});
35
36
test('non-objects', function (t) {
37
t.ok(equal(3, 3));
38
t.ok(equal('beep', 'beep'));
39
t.ok(equal('3', 3));
40
t.notOk(equal('3', 3, { strict: true }));
41
t.notOk(equal('3', [3]));
42
t.end();
43
});
44
45
test('arguments class', function (t) {
46
t.ok(equal(
47
(function(){return arguments})(1,2,3),
48
(function(){return arguments})(1,2,3),
49
"compares arguments"
50
));
51
t.notOk(equal(
52
(function(){return arguments})(1,2,3),
53
[1,2,3],
54
"differenciates array and arguments"
55
));
56
t.end();
57
});
58
59
test('test the arguments shim', function (t) {
60
t.ok(isArguments.supported((function(){return arguments})()));
61
t.notOk(isArguments.supported([1,2,3]));
62
63
t.ok(isArguments.unsupported((function(){return arguments})()));
64
t.notOk(isArguments.unsupported([1,2,3]));
65
66
t.end();
67
});
68
69
test('test the keys shim', function (t) {
70
t.deepEqual(objectKeys.shim({ a: 1, b : 2 }), [ 'a', 'b' ]);
71
t.end();
72
});
73
74
test('dates', function (t) {
75
var d0 = new Date(1387585278000);
76
var d1 = new Date('Fri Dec 20 2013 16:21:18 GMT-0800 (PST)');
77
t.ok(equal(d0, d1));
78
t.end();
79
});
80
81
test('buffers', function (t) {
82
t.ok(equal(Buffer('xyz'), Buffer('xyz')));
83
t.end();
84
});
85
86
test('booleans and arrays', function (t) {
87
t.notOk(equal(true, []));
88
t.end();
89
})
90
91