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("d3.selection"); |
|
8 |
|
9 suite.addBatch({ |
|
10 "selection": { |
|
11 topic: function() { |
|
12 return d3.selection(); |
|
13 }, |
|
14 "selects the document": function(selection) { |
|
15 assert.equal(selection.length, 1); |
|
16 assert.equal(selection[0].length, 1); |
|
17 assert.equal(selection[0][0], document); |
|
18 }, |
|
19 "is an instanceof d3.selection": function(selection) { |
|
20 assert.isTrue(selection instanceof d3.selection); |
|
21 }, |
|
22 "subselections are also instanceof d3.selection": function(selection) { |
|
23 assert.isTrue(selection.select("body") instanceof d3.selection); |
|
24 assert.isTrue(selection.selectAll("body") instanceof d3.selection); |
|
25 }, |
|
26 "selection prototype can be extended": function(selection) { |
|
27 d3.selection.prototype.foo = function(v) { return this.attr("foo", v); }; |
|
28 selection.select("body").foo(42); |
|
29 assert.equal(document.body.getAttribute("foo"), "42"); |
|
30 delete d3.selection.prototype.foo; |
|
31 } |
|
32 } |
|
33 }); |
|
34 |
|
35 suite.export(module); |