~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/d3/test/core/transition-test-select.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-10 14:28:58 UTC
  • Revision ID: package-import@ubuntu.com-20120410142858-nk453o1z7t7py3bs
Tags: 0.1.26
* Take ownership of the NetworkManager state variant on setup and
  unref it, plugging a memory leak.
* Log the reason the server rejected the submitted crash report.
* Send the Whoopsie version with each crash submission.
* Delete both .upload and .uploaded files after 14 days. Thanks
  Marc Deslauriers (LP: #973687).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require("../env");
 
2
 
 
3
var assert = require("assert");
 
4
 
 
5
module.exports = {
 
6
  topic: function() {
 
7
    var s = d3.select("body").append("div").selectAll("div")
 
8
        .data(["one", "two", "three", "four"])
 
9
      .enter().append("div")
 
10
        .attr("class", String);
 
11
 
 
12
    s.filter(function(d, i) { return i > 0; }).append("span");
 
13
    s[0][3] = null;
 
14
 
 
15
    return s.transition()
 
16
        .delay(function(d, i) { return i * 13; })
 
17
        .duration(function(d, i) { return i * 21; });
 
18
  },
 
19
 
 
20
  "selects the first matching element": function(transition) {
 
21
    var t = transition.select("span");
 
22
    assert.domEqual(t[0][1].node.parentNode, transition[0][1].node);
 
23
    assert.domEqual(t[0][2].node.parentNode, transition[0][2].node);
 
24
  },
 
25
  "ignores null elements": function(transition) {
 
26
    var t = transition.select("span");
 
27
    assert.isNull(t[0][3]);
 
28
  },
 
29
  "propagates data to the selected elements": function(transition) {
 
30
    var t = transition.select("span");
 
31
    assert.equal(t[0][1].node.__data__, "two");
 
32
    assert.equal(t[0][2].node.__data__, "three");
 
33
  },
 
34
  "propagates delay to the selected elements": function(transition) {
 
35
    var t = transition.select("span");
 
36
    assert.equal(t[0][1].delay, 13);
 
37
    assert.equal(t[0][2].delay, 26);
 
38
  },
 
39
  "propagates duration to the selected elements": function(transition) {
 
40
    var t = transition.select("span");
 
41
    assert.equal(t[0][1].duration, 21);
 
42
    assert.equal(t[0][2].duration, 42);
 
43
  },
 
44
  "does not propagate data if no data was specified": function(transition) {
 
45
    delete transition[0][1].node.__data__;
 
46
    delete transition[0][1].node.firstChild.__data__;
 
47
    var t = transition.select("span");
 
48
    assert.isUndefined(t[0][1].node.__data__);
 
49
    assert.equal(t[0][2].node.__data__, "three");
 
50
  },
 
51
  "returns null if no match is found": function(transition) {
 
52
    var t = transition.select("span");
 
53
    assert.isNull(t[0][0]);
 
54
  },
 
55
  "inherits transition id": function(transition) {
 
56
    var id = transition.id,
 
57
        t0 = transition.select("span"),
 
58
        t1 = transition.select("span");
 
59
    assert.equal(t0.id, id);
 
60
    assert.equal(t1.id, id);
 
61
  }
 
62
};