Skip to content

Commit

Permalink
Tests for d3.transition. #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 2, 2016
1 parent 1dcc93a commit cdf1c2a
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions test/transition/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,52 @@ var tape = require("tape"),
jsdom = require("jsdom"),
d3 = require("../../");

tape("d3.transition() returns a transition on the document element", function(test) {
tape("d3.transition() returns a transition on the document element with the null name", function(test) {
var document = global.document = jsdom.jsdom();
try {
test.equal(d3.transition().node(), document.documentElement);
var transition = d3.transition(),
schedule = document.documentElement.__transition[transition._id];
test.equal(transition.node(), document.documentElement);
test.strictEqual(schedule.name, null);
test.end();
} finally {
delete global.document;
}
});

tape("d3.transition(null) returns a transition on the document element with the null name", function(test) {
var document = global.document = jsdom.jsdom();
try {
var transition = d3.transition(null),
schedule = document.documentElement.__transition[transition._id];
test.equal(transition.node(), document.documentElement);
test.strictEqual(schedule.name, null);
test.end();
} finally {
delete global.document;
}
});

tape("d3.transition(undefined) returns a transition on the document element with the null name", function(test) {
var document = global.document = jsdom.jsdom();
try {
var transition = d3.transition(undefined),
schedule = document.documentElement.__transition[transition._id];
test.equal(transition.node(), document.documentElement);
test.strictEqual(schedule.name, null);
test.end();
} finally {
delete global.document;
}
});

tape("d3.transition(name) returns a transition on the document element with the specified name", function(test) {
var document = global.document = jsdom.jsdom();
try {
var transition = d3.transition("foo"),
schedule = document.documentElement.__transition[transition._id];
test.equal(transition.node(), document.documentElement);
test.strictEqual(schedule.name, "foo");
test.end();
} finally {
delete global.document;
Expand Down

0 comments on commit cdf1c2a

Please sign in to comment.