-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentries-test.js
39 lines (36 loc) · 1.06 KB
/
entries-test.js
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
var vows = require("vows"),
load = require("../load"),
assert = require("../assert");
var suite = vows.describe("d3.entries");
suite.addBatch({
"entries": {
topic: load("arrays/entries").expression("d3.entries"),
"enumerates every entry": function(entries) {
assert.deepEqual(entries({a: 1, b: 2}), [
{key: "a", value: 1},
{key: "b", value: 2}
]);
},
"includes entries defined on prototypes": function(entries) {
function abc() {
this.a = 1;
this.b = 2;
}
abc.prototype.c = 3;
assert.deepEqual(entries(new abc()), [
{key: "a", value: 1},
{key: "b", value: 2},
{key: "c", value: 3}
]);
},
"includes null or undefined values": function(entries) {
var v = entries({a: undefined, b: null, c: NaN});
assert.equal(v.length, 3);
assert.deepEqual(v[0], {key: "a", value: undefined});
assert.deepEqual(v[1], {key: "b", value: null});
assert.equal(v[2].key, "c");
assert.isNaN(v[2].value);
}
}
});
suite.export(module);