|
1 require("../env"); |
|
2 require("../../d3"); |
|
3 |
|
4 var vows = require("vows"), |
|
5 assert = require("assert"); |
|
6 |
|
7 var suite = vows.describe("d3.descending"); |
|
8 |
|
9 suite.addBatch({ |
|
10 "numbers": { |
|
11 "returns a negative number if a > b": function() { |
|
12 assert.isTrue(d3.descending(1, 0) < 0); |
|
13 }, |
|
14 "returns a positive number if a < b": function() { |
|
15 assert.isTrue(d3.descending(0, 1) > 0); |
|
16 }, |
|
17 "returns zero if a == b": function() { |
|
18 assert.equal(d3.descending(0, 0), 0); |
|
19 }, |
|
20 "returns NaN if a or b is undefined": function() { |
|
21 assert.isNaN(d3.descending(0, undefined)); |
|
22 assert.isNaN(d3.descending(undefined, 0)); |
|
23 assert.isNaN(d3.descending(undefined, undefined)); |
|
24 }, |
|
25 "returns NaN if a or b is NaN": function() { |
|
26 assert.isNaN(d3.descending(0, NaN)); |
|
27 assert.isNaN(d3.descending(NaN, 0)); |
|
28 assert.isNaN(d3.descending(NaN, NaN)); |
|
29 } |
|
30 } |
|
31 }); |
|
32 |
|
33 suite.addBatch({ |
|
34 "strings": { |
|
35 "returns a negative number if a > b": function() { |
|
36 assert.isTrue(d3.descending("b", "a") < 0); |
|
37 }, |
|
38 "returns a positive number if a < b": function() { |
|
39 assert.isTrue(d3.descending("a", "b") > 0); |
|
40 }, |
|
41 "returns zero if a == b": function() { |
|
42 assert.equal(d3.descending("a", "a"), 0); |
|
43 } |
|
44 } |
|
45 }); |
|
46 |
|
47 suite.export(module); |