Skip to content

Commit c162b58

Browse files
add tests (uncompleted)
1 parent 0b40261 commit c162b58

3 files changed

Lines changed: 78 additions & 33 deletions

File tree

test/bootstrap/index.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,11 @@
11
/*!
2-
* Attach chai to global should
2+
* Assert
33
*/
44

5-
global.chai = require('chai');
6-
global.should = global.chai.should();
7-
8-
/*!
9-
* Chai Plugins
10-
*/
11-
12-
//global.chai.use(require('chai-spies'));
13-
//global.chai.use(require('chai-http'));
5+
global.assert = require('simple-assert');
146

157
/*!
168
* Import project
179
*/
1810

1911
global.eql = require('../..');
20-
21-
/*!
22-
* Helper to load internals for cov unit tests
23-
*/
24-
25-
function req (name) {
26-
return process.env.eql_COV
27-
? require('../../lib-cov/eql/' + name)
28-
: require('../../lib/eql/' + name);
29-
}
30-
31-
/*!
32-
* Load unexposed modules for unit tests
33-
*/
34-
35-
global.__eql = {};

test/browser/index.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
77
<script src="../../node_modules/mocha/mocha.js"></script>
8-
<script src="../../node_modules/chai/chai.js"></script>
9-
<script>
10-
mocha.setup('bdd')
11-
var should = chai.should();
12-
</script>
138
<script src="../../build/build.js"></script>
149
<script>
1510
eql = require('deep-eql');
11+
assert = require('simple-assert');
1612
</script>
17-
<!-- <script src="../test.js"></script> -->
18-
<script>onload = function () {
13+
<script src="../eql.js"></script>
14+
<script>
15+
onload = function () {
1916
if (window.mochaPhantomJS) mochaPhantomJS.run()
2017
else mocha.run();
2118
}

test/eql.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
var tests = [];
2+
3+
/*!
4+
* sameValue
5+
*/
6+
7+
tests.push([ 'eql("x", "x")', 'x', 'x']);
8+
tests.push([ 'eql("x", "y")', 'x', 'y', true ]);
9+
tests.push([ 'eql(-0, +0)', -0, +0, true ]);
10+
tests.push([ 'eql(-0, -0)', -0, -0 ]);
11+
tests.push([ 'eql(+0, +0)', +0, +0 ]);
12+
tests.push([ 'eql(0, 0)', 0, 0 ]);
13+
tests.push([ 'eql(1, 1)', 1, 1 ]);
14+
tests.push([ 'eql(-1, 1)', -1, 1, true ]);
15+
16+
/*!
17+
* typeEqual
18+
*/
19+
20+
tests.push([ 'eql([], [])', [], [] ]);
21+
tests.push([ 'eql({}, {})', {}, {} ]);
22+
tests.push([ 'eql([], {})', [], {}, true ]);
23+
24+
(function() {
25+
tests.push([ 'eql([], arguments)', [], arguments, true ]);
26+
})();
27+
28+
(function() {
29+
var arg1 = arguments;
30+
(function() {
31+
var arg2 = arguments;
32+
tests.push([ 'eql(args1, args2)', arg1, arg2 ]);
33+
})();
34+
})();
35+
36+
/*!
37+
* dateEqual
38+
*/
39+
40+
var date1 = new Date();
41+
var date2 = new Date(date1.getTime() + 10);
42+
tests.push([ 'eql(date1, date1)', date1, date1 ]);
43+
tests.push([ 'eql(date1, date2)', date1, date2, true ]);
44+
45+
/*!
46+
* regexpEqual
47+
*/
48+
49+
tests.push([ 'eql(/\\\s/, new RegExp("\\\s"))', /\s/, new RegExp('\\\s') ]);
50+
tests.push([ 'eql(/\\\s/g, /\\\s/g)', /\s/g, /\s/g ]);
51+
tests.push([ 'eql(/\\\s/g, /\\\[/g)', /\s/g, /\[/g, true ]);
52+
53+
/*!
54+
* Test setup
55+
*/
56+
57+
describe('deep-equal', function() {
58+
tests.forEach(function(test, i) {
59+
var negate = test[3] && true === test[3];
60+
var title = '[' + (i + 1) + '] ';
61+
title += negate ? '(-) ' : '(+) ';
62+
title += test[0];
63+
64+
it(title, function() {
65+
if (negate) {
66+
assert(!eql(test[1], test[2]));
67+
} else {
68+
assert(eql(test[1], test[2]));
69+
}
70+
});
71+
});
72+
});

0 commit comments

Comments
 (0)