-
Notifications
You must be signed in to change notification settings - Fork 22.9k
/
brush-test.js
66 lines (59 loc) · 2.1 KB
/
brush-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require("../env");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("d3.svg.brush");
suite.addBatch({
"brush": {
topic: function() {
return d3.svg.brush;
},
"x": {
"defaults to null": function(brush) {
assert.isNull(brush().x());
}
},
"y": {
"defaults to null": function(brush) {
assert.isNull(brush().y());
}
},
"extent": {
"returns null when no scales are attached": function(brush) {
assert.isNull(brush().extent());
},
"returns a one-dimensional array if only x is defined": function(brush) {
var b = brush().x(d3.scale.linear());
assert.deepEqual(b.extent(), [0, 0]);
},
"takes a one-dimensional array if only x is defined": function(brush) {
var b = brush().x(d3.scale.linear()).extent([0.1, 0.4]);
assert.deepEqual(b.extent(), [0.1, 0.4]);
},
"returns a one-dimensional array if only y is defined": function(brush) {
var b = brush().y(d3.scale.linear());
assert.deepEqual(b.extent(), [0, 0]);
},
"takes a one-dimensional array if only y is defined": function(brush) {
var b = brush().y(d3.scale.linear()).extent([0.1, 0.4]);
assert.deepEqual(b.extent(), [0.1, 0.4]);
},
"returns a two-dimensional array if x and y are defined": function(brush) {
var b = brush().x(d3.scale.linear()).y(d3.scale.linear());
assert.deepEqual(b.extent(), [[0, 0], [0, 0]]);
},
"takes a two-dimensional array if x and y are defined": function(brush) {
var b = brush().x(d3.scale.linear()).y(d3.scale.linear()).extent([[0.1, 0.2], [0.3, 0.4]]);
assert.deepEqual(b.extent(), [[0.1, 0.2], [0.3, 0.4]]);
},
"preserves the set extent exactly": function(brush) {
var lo = new Number(0.1),
hi = new Number(0.3),
b = brush().x(d3.scale.linear()).extent([lo, hi]),
extent = b.extent();
assert.strictEqual(extent[0], lo);
assert.strictEqual(extent[1], hi);
}
}
}
});
suite.export(module);