Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept iterables. #153

Merged
merged 18 commits into from
Aug 19, 2020
Prev Previous commit
Next Next commit
Test for pie(iterable).
  • Loading branch information
mbostock committed Nov 19, 2019
commit 3672c0112fa2597e52cc942cf95386558fb0af1f
10 changes: 10 additions & 0 deletions test/pie-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ tape("pie(data) returns arcs in input order", function(test) {
test.end();
});

tape("pie(data) accepts an iterable", function(test) {
var p = shape.pie();
test.deepEqual(p(new Set([1, 3, 2])), [
{data: 1, value: 1, index: 2, startAngle: 5.235987755982988, endAngle: 6.283185307179585, padAngle: 0},
{data: 3, value: 3, index: 0, startAngle: 0.000000000000000, endAngle: 3.141592653589793, padAngle: 0},
{data: 2, value: 2, index: 1, startAngle: 3.141592653589793, endAngle: 5.235987755982988, padAngle: 0}
]);
test.end();
});

tape("pie(data) coerces the specified value to a number", function(test) {
var p = shape.pie(), three = {valueOf: function() { return 3; }};
test.deepEqual(p(["1", three, "2"]), [
Expand Down