-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransition-test-remove.js
57 lines (53 loc) · 1.75 KB
/
transition-test-remove.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
var assert = require("../assert");
module.exports = {
"on a new transition": {
topic: function(d3) {
var callback = this.callback,
t = d3.select("body").append("div").transition().remove();
t.each("end", function() {
process.nextTick(function() {
callback(null, t);
});
});
},
"removes the selected elements": function(transition) {
assert.domEqual(transition[0][0].parentNode, null);
}
},
"when the element is already removed": {
topic: function(d3) {
var callback = this.callback,
t = d3.select("body").append("div").remove().transition().remove();
t.each("end", function() {
process.nextTick(function() {
callback(null, t);
});
});
},
"does nothing": function(transition) {
assert.domEqual(transition[0][0].parentNode, null);
}
},
// Since these tests are triggered inside the end event of the above topic,
// transitions will inherit ids from the original transition. But we want to
// test concurrent transitions, so we use timeouts to avoid inheritance. This
// test also verifies that if multiple transitions are created at the same
// time, the last transition becomes the owner.
"when another transition is scheduled": {
topic: function(d3) {
var callback = this.callback,
s = d3.select("body").append("div");
setTimeout(function() {
s.transition().duration(150).remove().each("end", function() {
process.nextTick(function() {
callback(null, s);
});
});
s.transition().delay(250);
}, 10);
},
"does nothing": function(selection) {
assert.equal(selection[0][0].parentNode.tagName, "BODY");
}
}
};