-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-test.js
39 lines (34 loc) · 1023 Bytes
/
cluster-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
require("../env");
require("../../d3");
require("../../d3.layout");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("d3.layout.cluster");
suite.addBatch({
"cluster": {
topic: d3.layout.cluster,
"can handle an empty children array": function(cluster) {
assert.deepEqual(cluster.nodes({value: 1, children: [{value: 1, children: []}, {value: 1}]}).map(layout), [
{value: 1, depth: 0, x: 0.5, y: 0},
{value: 1, depth: 1, x: 0.25, y: 1},
{value: 1, depth: 1, x: 0.75, y: 1}
]);
},
"can handle zero-valued nodes": function(cluster) {
assert.deepEqual(cluster.nodes({value: 0, children: [{value: 0}, {value: 1}]}).map(layout), [
{value: 0, depth: 0, x: 0.5, y: 0},
{value: 0, depth: 1, x: 0.25, y: 1},
{value: 1, depth: 1, x: 0.75, y: 1}
]);
}
}
});
function layout(node) {
return {
value: node.value,
depth: node.depth,
x: node.x,
y: node.y
};
}
suite.export(module);