equal
deleted
inserted
replaced
|
1 require("../env"); |
|
2 require("../../d3"); |
|
3 |
|
4 var vows = require("vows"), |
|
5 assert = require("assert"); |
|
6 |
|
7 var suite = vows.describe("selection.map"); |
|
8 |
|
9 suite.addBatch({ |
|
10 "select(body)": { |
|
11 topic: function() { |
|
12 return d3.select("body").html(""); |
|
13 }, |
|
14 "updates the data according to the map function": function(body) { |
|
15 body.data([42]).map(function(d, i) { return d + i; }); |
|
16 assert.equal(document.body.__data__, 42); |
|
17 }, |
|
18 "returns the current selection": function(body) { |
|
19 assert.isTrue(body.map(function() { return 1; }) === body); |
|
20 } |
|
21 } |
|
22 }); |
|
23 |
|
24 suite.addBatch({ |
|
25 "selectAll(div)": { |
|
26 topic: function() { |
|
27 return d3.select("body").html("").selectAll("div").data(d3.range(2)).enter().append("div"); |
|
28 }, |
|
29 "updates the data according to the map function": function(div) { |
|
30 div.data([42, 43]).map(function(d, i) { return d + i; }); |
|
31 assert.equal(div[0][0].__data__, 42); |
|
32 assert.equal(div[0][1].__data__, 44); |
|
33 }, |
|
34 "returns the current selection": function(div) { |
|
35 assert.isTrue(div.map(function() { return 1; }) === div); |
|
36 }, |
|
37 "ignores null nodes": function(div) { |
|
38 var some = d3.selectAll("div").data([42, 43]); |
|
39 some[0][1] = null; |
|
40 some.map(function() { return 1; }); |
|
41 assert.equal(div[0][0].__data__, 1); |
|
42 assert.equal(div[0][1].__data__, 43); |
|
43 } |
|
44 } |
|
45 }); |
|
46 |
|
47 suite.export(module); |