toolkit/javascript/d3/test/core/transition-test-style.js
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     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         .style("background-color", "white")
       
    12         .style("color", "red")
       
    13         .style("display", "none")
       
    14         .style("font-size", "20px");
       
    15 
       
    16     var t = s.transition()
       
    17         .style("display", null)
       
    18         .style("font-size", function() { return null; })
       
    19         .style("display", null)
       
    20         .style("background-color", "green")
       
    21         .style("background-color", "red")
       
    22         .style("color", function() { return "green"; }, "important")
       
    23         .each("end", function() { cb(null, {selection: s, transition: t}); });
       
    24   },
       
    25   "defines the corresponding style tween": function(result) {
       
    26     assert.typeOf(result.transition.tween("style.background-color"), "function");
       
    27     assert.typeOf(result.transition.tween("style.color"), "function");
       
    28   },
       
    29   "the last style operator takes precedence": function(result) {
       
    30     assert.equal(result.selection.style("background-color"), "#ff0000");
       
    31   },
       
    32   "sets a property as a string": function(result) {
       
    33     assert.equal(result.selection.style("background-color"), "#ff0000");
       
    34   },
       
    35   "sets a property as a function": function(result) {
       
    36     assert.equal(result.selection.style("color"), "#008000");
       
    37   },
       
    38   "observes the specified priority": function(result) {
       
    39     var style = result.selection.node().style;
       
    40     assert.equal(style.getPropertyPriority("background-color"), "");
       
    41     assert.equal(style.getPropertyPriority("color"), "important");
       
    42   },
       
    43   "removes a property using a constant null": function(result) {
       
    44     assert.equal(result.selection.style("display"), "");
       
    45   },
       
    46   "removes a property using a function null": function(result) {
       
    47     assert.equal(result.selection.style("font-size"), "");
       
    48   }
       
    49 };