Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Sep 2, 2019
1 parent 7efa810 commit 6f34f42
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/radial-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tape("scaleRadial(domain, range) sets the range", function(test) {
});

tape("radial(x) maps a domain value x to a range value y", function(test) {
test.equal(scale.scaleRadial().range([1, 2])(0.5), 1.5811388300841898);
test.equal(scale.scaleRadial([1, 2])(0.5), 1.5811388300841898);
test.end();
});

Expand Down Expand Up @@ -78,3 +78,15 @@ tape("radial.unknown(unknown)(NaN) returns the specified unknown value", functio
test.strictEqual(scale.scaleRadial().unknown("foo")(NaN), "foo");
test.end();
});

tape("radial(x) can handle a negative range", function(test) {
test.equal(scale.scaleRadial([-1, -2])(0.5), -1.5811388300841898);
test.end();
});

tape("radial(x) can clamp negative values", function(test) {
test.equal(scale.scaleRadial([-1, -2]).clamp(true)(-0.5), -1);
test.equal(scale.scaleRadial().clamp(true)(-0.5), 0);
test.equal(scale.scaleRadial([-0.25, 0], [1, 2]).clamp(true)(-0.5), 1);
test.end();
});

0 comments on commit 6f34f42

Please sign in to comment.