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