Commit a4fed02b authored by Mike Bostock's avatar Mike Bostock
Browse files

Get most transition tests working again.

parent bd09d37e
......@@ -49,6 +49,7 @@ import "call";
import "empty";
import "node";
import "enter";
import "transition";
var d3_selectionRoot = d3_selection([[d3_document]]);
......
import "selection";
import "../transition/transition";
d3_selectionPrototype.transition = function() {
var id = d3_transitionInheritId || ++d3_transitionId,
......
import "../selection/transition";
import "transition";
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
var s = d3.select("body").append("div")
.attr("display", "none")
.attr("font-size", "20px")
......
require("../env");
var assert = require("../assert");
var assert = require("../assert"),
interpolateHsl = require("../../").interpolateHsl;
module.exports = {
topic: function() {
topic: function(d3) {
var cb = this.callback,
dd = [],
ii = [],
......@@ -13,7 +12,7 @@ module.exports = {
var s = d3.select("body").html("").append("div").selectAll("div")
.data(["red", "green"])
.enter().append("div")
.attr("color", function(d) { return d3.rgb(d)+""; });
.attr("color", function(d, i) { return i ? "#008000" : "#ff0000"; });
var t = s.transition()
.attrTween("color", tween);
......@@ -30,7 +29,7 @@ module.exports = {
value: vv,
context: tt
});
return i && d3.interpolateHsl(v, "blue");
return i && interpolateHsl(v, "blue");
}
},
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").append("div").transition();
},
"calls the function once": function(transition) {
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").html("").selectAll()
.data(["foo", "bar"])
.enter().append("div")
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").html("").selectAll()
.data(["foo", "bar"])
.enter().append("div")
......
require("../env");
var assert = require("../assert");
module.exports = {
"start": {
topic: function() {
topic: function(d3) {
var cb = this.callback,
div = d3.select("body").html("").selectAll().data(["foo", "bar"]).enter().append("div").attr("class", String),
transition = div.transition().delay(350),
......@@ -76,7 +74,7 @@ module.exports = {
},
"end": {
topic: function() {
topic: function(d3) {
var cb = this.callback,
div = d3.select("body").html("").selectAll().data(["foo", "bar"]).enter().append("div").attr("class", String),
transition = div.transition().duration(350),
......
require("../env");
var assert = require("../assert");
var assert = require("../assert"),
merge = require("../../").merge;
var datum = {};
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").html("").selectAll("div")
.data([0, 1])
.enter().append("div")
......@@ -25,7 +24,7 @@ module.exports = {
assert.isTrue(some[1][0] === span[1][0]);
},
"removes non-matching elements": function(span) {
var some = d3.merge(span.filter(function(d, i) { return d & 1; }));
var some = merge(span.filter(function(d, i) { return d & 1; }));
assert.equal(some.indexOf(span[0][0]), -1);
assert.equal(some.indexOf(span[1][0]), -1);
},
......@@ -50,12 +49,13 @@ module.exports = {
span.filter(function(d, i) { return d & 1; }).each(function(d, i) { indexes.push(i); });
assert.deepEqual(indexes, [0, 0]);
},
"ignores null nodes": function() {
var span = d3.selectAll("span");
"ignores null nodes": function(span) {
var node = span[0][1];
span[0][1] = null;
var some = span.filter(function(d, i) { return d & 1; });
assert.isTrue(some[0][0] === span[0][3]);
assert.equal(some.length, 1);
assert.equal(some.length, 2);
span[0][1] = node;
},
"can be specified as a selector": function(span) {
var some = span.filter(".foo");
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
return d3.select("body").append("div").transition();
},
"has a positive integer id": function(transition) {
var id = transition.id;
assert.isTrue(id > 0);
assert.equal(~~id, id);
"on a new transition": {
topic: function(d3) {
return d3.select("body").append("div").transition();
},
"has a positive integer id": function(transition) {
var id = transition.id;
assert.isTrue(id > 0);
assert.equal(~~id, id);
}
},
"increases monotonically across transitions": function(transition) {
var t0 = d3.select("body").append("div").transition(),
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
var cb = this.callback,
t = d3.select("body").append("div").transition().remove();
t.each("end", function() { cb(null, t); });
},
"removes the selected elements": function(transition) {
assert.domEqual(transition[0][0].parentNode, null);
"on a new transition": {
topic: function(d3) {
var cb = this.callback,
t = d3.select("body").append("div").transition().remove();
t.each("end", function() { cb(null, t); });
},
"removes the selected elements": function(transition) {
assert.domEqual(transition[0][0].parentNode, null);
}
},
"when the element is already removed": {
topic: function() {
topic: function(d3) {
var cb = this.callback,
t = d3.select("body").append("div").remove().transition().remove();
t.each("end", function() { cb(null, t); });
......@@ -30,7 +30,7 @@ module.exports = {
// time, the last transition becomes the owner.
"when another transition is scheduled": {
topic: function() {
topic: function(d3) {
var cb = this.callback,
s = d3.select("body").append("div");
setTimeout(function() {
......@@ -39,7 +39,7 @@ module.exports = {
}, 10);
},
"does nothing": function(selection) {
assert.domEqual(selection[0][0].parentNode, document.body);
assert.equal(selection[0][0].parentNode.tagName, "BODY");
}
}
};
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
var s = d3.select("body").append("div").selectAll("div")
.data(["one", "two", "three", "four"])
.enter().append("div")
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
var s = d3.select("body").append("div").selectAll("div")
.data(["one", "two", "three", "four"])
.enter().append("div")
......@@ -51,8 +49,8 @@ module.exports = {
assert.equal(t0.id, id);
assert.equal(t1.id, id);
},
"groups are not instances of NodeList": function(transition) {
"groups are arrays, not instances of NodeList": function(transition) {
var t = transition.selectAll(function() { return this.getElementsByClassName("span"); });
assert.isFalse(t[0] instanceof window.NodeList);
assert.isTrue(Array.isArray(t[0]));
}
};
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
var s = d3.select("body").append("div")
.style("background-color", "white")
.style("color", "red")
......
require("../env");
var assert = require("../assert");
var assert = require("../assert"),
interpolateHsl = require("../../").interpolateHsl;
module.exports = {
topic: function() {
topic: function(d3) {
var cb = this.callback,
dd = [],
ii = [],
......@@ -33,7 +32,7 @@ module.exports = {
context: tt,
fails: fails
});
return i && d3.interpolateHsl(v, "blue");
return i && interpolateHsl(v, "blue");
}
},
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").append("div").text("foo").transition().text("bar");
},
"sets the text tween": function(div) {
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
return d3.select("body").append("div").transition();
},
"is approximately equal to now": function(transition) {
var time = transition[0][0].__transition__[transition.id].time;
assert.inDelta(time, Date.now(), 20);
"on a new transition": {
topic: function(d3) {
return d3.select("body").append("div").transition();
},
"is approximately equal to now": function(transition) {
var time = transition[0][0].__transition__[transition.id].time;
assert.inDelta(time, Date.now(), 20);
}
},
"increases monotonically across transitions": function(transition) {
"increases monotonically across transitions": function(d3) {
var now = Date.now, then = Date.now();
try {
Date.now = function() { return ++then; };
......@@ -21,7 +21,7 @@ module.exports = {
Date.now = now;
}
},
"is inherited by subtransitions": function(transition) {
"is inherited by subtransitions": function(d3) {
var now = Date.now, then = Date.now();
try {
Date.now = function() { return ++then; };
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
return d3.select("body").append("div").transition()
.delay(101)
.duration(152)
......@@ -28,13 +26,14 @@ module.exports = {
"while transitioning": {
topic: function(t1) {
var t2 = t1.transition(),
cb = this.callback;
t2.each("start", function() {
d3.timer(function() {
cb(null, t2);
return true;
});
var callback = this.callback;
var t2 = t1.transition().tween("custom", function() {
return function(t) {
if (callback) {
callback(null, t2);
callback = null;
}
};
});
},
"increments the lock's reference count": function(t2) {
......@@ -47,7 +46,7 @@ module.exports = {
var cb = this.callback;
var t2 = t1.transition();
t2.each("end", function() {
d3.timer(function() {
setTimeout(function() {
cb(null, t2);
return true;
}, 50);
......
require("../env");
var assert = require("../assert");
module.exports = {
topic: function() {
topic: function(d3) {
var cb = this.callback,
dd = [],
ii = [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment