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.html"); |
|
8 |
|
9 suite.addBatch({ |
|
10 "html": { |
|
11 topic: function() { |
|
12 var cb = this.callback; |
|
13 return d3.html("examples/data/sample.html", function(document) { |
|
14 cb(null, document); |
|
15 }); |
|
16 }, |
|
17 "invokes the callback with the loaded html": function(document) { |
|
18 assert.equal(document.getElementsByTagName("H1")[0].textContent, "Hello & world!"); |
|
19 }, |
|
20 "override the mime type to text/html": function(xml) { |
|
21 assert.equal(XMLHttpRequest._last._info.mimeType, "text/html"); |
|
22 }, |
|
23 "": { |
|
24 topic: function() { |
|
25 var cb = this.callback; |
|
26 return d3.html("//does/not/exist.html", function(document) { |
|
27 cb(null, document); |
|
28 }); |
|
29 }, |
|
30 "invokes the callback with null when an error occurs": function(document) { |
|
31 assert.isNull(document); |
|
32 } |
|
33 } |
|
34 } |
|
35 }); |
|
36 |
|
37 suite.export(module); |