forked from d3/d3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselection-empty-test.js
More file actions
50 lines (45 loc) · 1.26 KB
/
selection-empty-test.js
File metadata and controls
50 lines (45 loc) · 1.26 KB
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
require("../env");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("selection.empty");
suite.addBatch({
"select(body)": {
topic: function() {
return d3.select("body").html("");
},
"returns true for empty selections": function(body) {
assert.isTrue(body.select("foo").empty());
},
"returns false for non-empty selections": function(body) {
assert.isFalse(body.empty());
},
"ignores null nodes": function(body) {
var some = d3.select("body");
some[0][0] = null;
assert.isTrue(some.empty());
}
}
});
suite.addBatch({
"selectAll(div)": {
topic: function() {
var body = d3.select("body").html("");
body.append("div").append("span");
body.append("div");
return body.selectAll("div");
},
"returns true for empty selections": function(div) {
assert.isTrue(div.select("foo").empty());
},
"returns false for non-empty selections": function(div) {
assert.isFalse(div.empty());
assert.isFalse(div.select("span").empty());
},
"ignores null nodes": function(div) {
var some = d3.selectAll("div");
some[0][0] = null;
assert.isTrue(some.select("span").empty());
}
}
});
suite.export(module);