Spaces:
Sleeping
Sleeping
File size: 2,201 Bytes
cdb0d23 |
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
var test = require('tape');
var equal = require('../');
var isArguments = require('../lib/is_arguments.js');
var objectKeys = require('../lib/keys.js');
test('equal', function (t) {
t.ok(equal(
{ a : [ 2, 3 ], b : [ 4 ] },
{ a : [ 2, 3 ], b : [ 4 ] }
));
t.end();
});
test('not equal', function (t) {
t.notOk(equal(
{ x : 5, y : [6] },
{ x : 5, y : 6 }
));
t.end();
});
test('nested nulls', function (t) {
t.ok(equal([ null, null, null ], [ null, null, null ]));
t.end();
});
test('strict equal', function (t) {
t.notOk(equal(
[ { a: 3 }, { b: 4 } ],
[ { a: '3' }, { b: '4' } ],
{ strict: true }
));
t.end();
});
test('non-objects', function (t) {
t.ok(equal(3, 3));
t.ok(equal('beep', 'beep'));
t.ok(equal('3', 3));
t.notOk(equal('3', 3, { strict: true }));
t.notOk(equal('3', [3]));
t.end();
});
test('arguments class', function (t) {
t.ok(equal(
(function(){return arguments})(1,2,3),
(function(){return arguments})(1,2,3),
"compares arguments"
));
t.notOk(equal(
(function(){return arguments})(1,2,3),
[1,2,3],
"differenciates array and arguments"
));
t.end();
});
test('test the arguments shim', function (t) {
t.ok(isArguments.supported((function(){return arguments})()));
t.notOk(isArguments.supported([1,2,3]));
t.ok(isArguments.unsupported((function(){return arguments})()));
t.notOk(isArguments.unsupported([1,2,3]));
t.end();
});
test('test the keys shim', function (t) {
t.deepEqual(objectKeys.shim({ a: 1, b : 2 }), [ 'a', 'b' ]);
t.end();
});
test('dates', function (t) {
var d0 = new Date(1387585278000);
var d1 = new Date('Fri Dec 20 2013 16:21:18 GMT-0800 (PST)');
t.ok(equal(d0, d1));
t.end();
});
test('buffers', function (t) {
t.ok(equal(Buffer('xyz'), Buffer('xyz')));
t.end();
});
test('booleans and arrays', function (t) {
t.notOk(equal(true, []));
t.end();
})
test('null == undefined', function (t) {
t.ok(equal(null, undefined))
t.notOk(equal(null, undefined, { strict: true }))
t.end()
})
|