Skip to content

Commit 886b659

Browse files
committed
Another test for empty children arrays.
This tests for the issue fixed in 6804a60.
1 parent 6804a60 commit 886b659

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

test/layout/tree-test.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,32 @@ suite.addBatch({
1111
"tree": {
1212
topic: d3.layout.tree,
1313
"can handle an empty children array": function(tree) {
14-
assert.deepEqual(tree.nodes({children: []}), [
15-
{children: [], depth: 0, x: 0.5, y: 0}
14+
assert.deepEqual(tree.nodes({children: []}).map(layout), [
15+
{depth: 0, x: 0.5, y: 0}
16+
]);
17+
var result = tree.nodes({children: [
18+
{children: []},
19+
{children: [{}]},
20+
{children: [{}]}
21+
]}).map(layout);
22+
assert.deepEqual(result, [
23+
{depth: 0, x: .5, y: 0},
24+
{depth: 1, x: .125, y: 0.5},
25+
{depth: 1, x: .375, y: 0.5},
26+
{depth: 2, x: .375, y: 1},
27+
{depth: 1, x: .875, y: 0.5},
28+
{depth: 2, x: .875, y: 1}
1629
]);
1730
}
1831
}
1932
});
2033

34+
function layout(node) {
35+
return {
36+
depth: node.depth,
37+
x: node.x,
38+
y: node.y
39+
};
40+
}
41+
2142
suite.export(module);

0 commit comments

Comments
 (0)