2011-08-17 09:28:15 +04:00
|
|
|
require("../env");
|
|
|
|
|
|
|
|
var vows = require("vows"),
|
|
|
|
assert = require("assert");
|
|
|
|
|
|
|
|
var suite = vows.describe("d3.json");
|
|
|
|
|
|
|
|
suite.addBatch({
|
|
|
|
"json": {
|
|
|
|
topic: function() {
|
|
|
|
var cb = this.callback;
|
2012-10-06 04:05:59 +04:00
|
|
|
d3.json("examples/data/sample.json", function(error, json) {
|
2011-08-17 09:28:15 +04:00
|
|
|
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;
|
2012-10-06 04:05:59 +04:00
|
|
|
d3.json("//does/not/exist.json", function(error, json) {
|
2011-08-17 09:28:15 +04:00
|
|
|
cb(null, json);
|
|
|
|
});
|
|
|
|
},
|
2012-10-06 04:05:59 +04:00
|
|
|
"invokes the callback with undefined when an error occurs": function(json) {
|
|
|
|
assert.isUndefined(json);
|
2011-08-17 09:28:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
suite.export(module);
|