-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson-test.js
More file actions
37 lines (33 loc) · 954 Bytes
/
Copy pathjson-test.js
File metadata and controls
37 lines (33 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require("../env");
require("../../d3");
var vows = require("vows"),
assert = require("assert");
var suite = vows.describe("d3.json");
suite.addBatch({
"json": {
topic: function() {
var cb = this.callback;
return d3.json("examples/data/sample.json", function(json) {
cb(null, json);
});
},
"invokes the callback with the loaded JSON": function(json) {
assert.deepEqual(json, [{"Hello":42,"World":"\"fish\""}]);
},
"overrides the mime type to application/json": function(json) {
assert.equal(XMLHttpRequest._last._info.mimeType, "application/json");
},
"": {
topic: function() {
var cb = this.callback;
return d3.json("//does/not/exist.json", function(json) {
cb(null, json);
});
},
"invokes the callback with null when an error occurs": function(json) {
assert.isNull(json);
}
}
}
});
suite.export(module);