3
var assert = require("assert");
7
var s = d3.select("body").append("div").selectAll("div")
8
.data(["one", "two", "three", "four"])
10
.attr("class", String);
12
s.filter(function(d, i) { return i > 0; }).append("span");
16
.delay(function(d, i) { return i * 13; })
17
.duration(function(d, i) { return i * 21; });
20
"selects the first matching element": function(transition) {
21
var t = transition.select("span");
22
assert.domEqual(t[0][1].node.parentNode, transition[0][1].node);
23
assert.domEqual(t[0][2].node.parentNode, transition[0][2].node);
25
"ignores null elements": function(transition) {
26
var t = transition.select("span");
27
assert.isNull(t[0][3]);
29
"propagates data to the selected elements": function(transition) {
30
var t = transition.select("span");
31
assert.equal(t[0][1].node.__data__, "two");
32
assert.equal(t[0][2].node.__data__, "three");
34
"propagates delay to the selected elements": function(transition) {
35
var t = transition.select("span");
36
assert.equal(t[0][1].delay, 13);
37
assert.equal(t[0][2].delay, 26);
39
"propagates duration to the selected elements": function(transition) {
40
var t = transition.select("span");
41
assert.equal(t[0][1].duration, 21);
42
assert.equal(t[0][2].duration, 42);
44
"does not propagate data if no data was specified": function(transition) {
45
delete transition[0][1].node.__data__;
46
delete transition[0][1].node.firstChild.__data__;
47
var t = transition.select("span");
48
assert.isUndefined(t[0][1].node.__data__);
49
assert.equal(t[0][2].node.__data__, "three");
51
"returns null if no match is found": function(transition) {
52
var t = transition.select("span");
53
assert.isNull(t[0][0]);
55
"inherits transition id": function(transition) {
56
var id = transition.id,
57
t0 = transition.select("span"),
58
t1 = transition.select("span");
59
assert.equal(t0.id, id);
60
assert.equal(t1.id, id);