-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpartition-test.js
More file actions
39 lines (34 loc) · 1.01 KB
/
Copy pathpartition-test.js
File metadata and controls
39 lines (34 loc) · 1.01 KB
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.partition");
suite.addBatch({
"partition": {
topic: function() {
return d3.layout.partition;
},
"ignores zero values": function(partition) {
var p = partition().size([3, 3]);
assert.deepEqual(p({children: [{value: 1}, {value: 0}, {value: 2}, {children: [{value: 0}, {value: 0}]}]}).map(metadata), [
{x: 0, y: 0, dx: 3, dy: 1},
{x: 2, y: 1, dx: 1, dy: 1},
{x: 3, y: 1, dx: 0, dy: 1},
{x: 0, y: 1, dx: 2, dy: 1},
{x: 3, y: 1, dx: 0, dy: 1},
{x: 3, y: 2, dx: 0, dy: 1},
{x: 3, y: 2, dx: 0, dy: 1}
]);
}
}
});
function metadata(node) {
var metadata = {};
if ("x" in node) metadata.x = node.x;
if ("y" in node) metadata.y = node.y;
if ("dx" in node) metadata.dx = node.dx;
if ("dy" in node) metadata.dy = node.dy;
return metadata;
}
suite.export(module);