Skip to content

Commit

Permalink
Add test for leading zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Nov 17, 2016
1 parent a1a0399 commit b59d1f1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/treemap/squarify-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,32 @@ tape("treemapSquarify(parent, x0, y0, x1, y1) handles a degenerate wide empty pa
]);
test.end();
});

tape("treemapSquarify(parent, x0, y0, x1, y1) handles a leading zero value", function(test) {
var tile = d3_hierarchy.treemapSquarify,
root = {
value: 24,
children: [
{value: 0},
{value: 6},
{value: 6},
{value: 4},
{value: 3},
{value: 2},
{value: 2},
{value: 1}
]
};
tile(root, 0, 0, 6, 4);
test.deepEqual(root.children.map(round), [
{x0: 0.00, x1: 3.00, y0: 0.00, y1: 0.00},
{x0: 0.00, x1: 3.00, y0: 0.00, y1: 2.00},
{x0: 0.00, x1: 3.00, y0: 2.00, y1: 4.00},
{x0: 3.00, x1: 4.71, y0: 0.00, y1: 2.33},
{x0: 4.71, x1: 6.00, y0: 0.00, y1: 2.33},
{x0: 3.00, x1: 5.40, y0: 2.33, y1: 3.17},
{x0: 3.00, x1: 5.40, y0: 3.17, y1: 4.00},
{x0: 5.40, x1: 6.00, y0: 2.33, y1: 4.00}
]);
test.end();
});

0 comments on commit b59d1f1

Please sign in to comment.