equal
deleted
inserted
replaced
|
1 require("../env"); |
|
2 require("../../d3"); |
|
3 |
|
4 var assert = require("assert"); |
|
5 |
|
6 module.exports = { |
|
7 topic: function() { |
|
8 return d3.select("body").append("div").transition(); |
|
9 }, |
|
10 "is approximately equal to now": function(transition) { |
|
11 var time = transition.time; |
|
12 assert.inDelta(time, Date.now(), 20); |
|
13 }, |
|
14 "increases monotonically across transitions": function(transition) { |
|
15 var now = Date.now, then = Date.now(); |
|
16 try { |
|
17 Date.now = function() { return ++then; }; |
|
18 var t0 = d3.select("body").append("div").transition(), |
|
19 t1 = d3.select("body").append("div").transition(); |
|
20 assert.isTrue(t1.time > t0.time); |
|
21 } finally { |
|
22 Date.now = now; |
|
23 } |
|
24 }, |
|
25 "is inherited by subtransitions": function(transition) { |
|
26 var now = Date.now, then = Date.now(); |
|
27 try { |
|
28 Date.now = function() { return ++then; }; |
|
29 var t0 = d3.select("body").append("div").transition(), |
|
30 t1 = t0.transition(); |
|
31 assert.equal(t1.time, t0.time); |
|
32 } finally { |
|
33 Date.now = now; |
|
34 } |
|
35 } |
|
36 }; |