diff -r efd9c589177a -r c0b4a8b5a012 toolkit/javascript/d3/test/core/xml-test.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/javascript/d3/test/core/xml-test.js Thu Apr 10 14:20:23 2014 +0200 @@ -0,0 +1,48 @@ +require("../env"); +require("../../d3"); + +var vows = require("vows"), + assert = require("assert"); + +var suite = vows.describe("d3.xml"); + +suite.addBatch({ + "xml": { + topic: function() { + var cb = this.callback; + return d3.xml("examples/data/sample.xml", function(xml) { + cb(null, xml); + }); + }, + "invokes the callback with the loaded xml": function(xml) { + assert.deepEqual(xml, {_xml: "\n\n \n\n"}); + }, + "does not override the mime type by default": function(xml) { + assert.isUndefined(XMLHttpRequest._last._info.mimeType); + }, + "": { + topic: function() { + var cb = this.callback; + return d3.xml("examples/data/sample.txt", "application/xml+sample", function(xml) { + cb(null, xml); + }); + }, + "observes the optional mime type": function(xml) { + assert.equal(XMLHttpRequest._last._info.mimeType, "application/xml+sample"); + } + }, + " ": { + topic: function() { + var cb = this.callback; + return d3.xml("//does/not/exist.xml", function(xml) { + cb(null, xml); + }); + }, + "invokes the callback with null when an error occurs": function(xml) { + assert.isNull(xml); + } + } + } +}); + +suite.export(module);