--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/toolkit/javascript/d3/test/csv/csv-test.js Thu Apr 10 14:20:23 2014 +0200
@@ -0,0 +1,38 @@
+require("../env");
+require("../../d3");
+require("../../d3.csv");
+
+var vows = require("vows"),
+ assert = require("assert");
+
+var suite = vows.describe("d3.csv");
+
+suite.addBatch({
+ "csv": {
+ topic: function() {
+ var cb = this.callback;
+ return d3.csv("examples/data/sample.csv", function(csv) {
+ cb(null, csv);
+ });
+ },
+ "invokes the callback with the parsed CSV": function(csv) {
+ assert.deepEqual(csv, [{"Hello":42,"World":"\"fish\""}]);
+ },
+ "overrides the mime type to text/csv": function(csv) {
+ assert.equal(XMLHttpRequest._last._info.mimeType, "text/csv");
+ },
+ "": {
+ topic: function() {
+ var cb = this.callback;
+ return d3.csv("//does/not/exist.csv", function(csv) {
+ cb(null, csv);
+ });
+ },
+ "invokes the callback with null when an error occurs": function(csv) {
+ assert.isNull(csv);
+ }
+ }
+ }
+});
+
+suite.export(module);