Sha256: 2dfba145287fd54f48edb09e2351a35bb1b59a96df6e67420d4754b75f2f7727

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

var vows = require("vows"),
    load = require("../load"),
    assert = require("../assert");

var suite = vows.describe("d3.selection");

suite.addBatch({
  "selection": {
    topic: load("selection/selection").document(),
    "selects the document element": function(d3) {
      var selection = d3.selection();
      assert.equal(selection.length, 1);
      assert.equal(selection[0].length, 1);
      assert.equal(selection[0][0].nodeType, 1);
      assert.equal(selection[0][0].tagName, "HTML");
    },
    "the parentNode is also the document element": function(d3) {
      var parentNode = d3.selection()[0].parentNode;
      assert.equal(parentNode.nodeType, 1);
      assert.equal(parentNode.tagName, "HTML");
    },
    "is an instanceof d3.selection": function(d3) {
      assert.instanceOf(d3.selection(), d3.selection);
    },
    "subselections are also instanceof d3.selection": function(d3) {
      assert.instanceOf(d3.selection().select("body"), d3.selection);
      assert.instanceOf(d3.selection().selectAll("body"), d3.selection);
    },
    "selection prototype can be extended": function(d3) {
      d3.selection.prototype.foo = function(v) { return this.attr("foo", v); };
      var body = d3.selection().select("body").foo(42);
      assert.equal(body.attr("foo"), "42");
      delete d3.selection.prototype.foo;
    }
  }
});

suite.export(module);

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
stripchart-0.0.3 lib/stripchart/public/components/d3/test/selection/selection-test.js
stripmem-0.0.3 lib/stripmem/public/components/d3/test/selection/selection-test.js
stripmem-0.0.2 lib/stripmem/public/components/d3/test/selection/selection-test.js
stripmem-0.0.1 lib/stripmem/public/components/d3/test/selection/selection-test.js