|
1 require("../env"); |
|
2 require("../../d3"); |
|
3 |
|
4 var assert = require("assert"); |
|
5 |
|
6 module.exports = { |
|
7 topic: function() { |
|
8 var cb = this.callback; |
|
9 |
|
10 var s = d3.select("body").append("div") |
|
11 .attr("display", "none") |
|
12 .attr("font-size", "20px") |
|
13 .attr("width", 20) |
|
14 .attr("color", "red") |
|
15 .attr("xlink:type", "simple") |
|
16 .attr("xlink:href", "http://mbostock.github.com/d3/"); |
|
17 |
|
18 var t = s.transition() |
|
19 .attr("display", null) |
|
20 .attr("font-size", function() { return null; }) |
|
21 .attr("display", null) |
|
22 .attr("width", 100) |
|
23 .attr("width", 200) |
|
24 .attr("color", function() { return "green"; }) |
|
25 .attr("xlink:href", null) |
|
26 .attr("xlink:type", function() { return null; }) |
|
27 .each("end", function() { cb(null, {selection: s, transition: t}); }); |
|
28 }, |
|
29 "defines the corresponding attr tween": function(result) { |
|
30 assert.typeOf(result.transition.tween("attr.width"), "function"); |
|
31 assert.typeOf(result.transition.tween("attr.color"), "function"); |
|
32 }, |
|
33 "the last attr operator takes precedence": function(result) { |
|
34 assert.equal(result.selection.attr("width"), "200"); |
|
35 }, |
|
36 "sets an attribute as a number": function(result) { |
|
37 assert.equal(result.selection.attr("width"), "200"); |
|
38 }, |
|
39 "sets an attribute as a function": function(result) { |
|
40 assert.equal(result.selection.attr("color"), "#008000"); |
|
41 }, |
|
42 "removes an attribute using a constant null": function(result) { |
|
43 assert.equal(result.selection.attr("display"), ""); |
|
44 }, |
|
45 "removes an attribute using a function null": function(result) { |
|
46 assert.equal(result.selection.attr("font-size"), ""); |
|
47 }, |
|
48 "removes a namespaced attribute using a constant null": function(result) { |
|
49 assert.equal(result.selection.attr("xlink:href"), ""); |
|
50 }, |
|
51 "removes a namespaced attribute using a function null": function(result) { |
|
52 assert.equal(result.selection.attr("xlink:type"), ""); |
|
53 } |
|
54 }; |