diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-02 19:24:45 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-02 19:24:45 +0200 |
commit | 0d8bba263dc195147d6fdb09662e7926f0a58b3e (patch) | |
tree | 4c570b4376c323e585120e7695b8715be7aa8881 /web/nms.gathering.org/speedometer/d3-master/test/load.js | |
parent | e4354b47bd8891c5b1ee591fdf74b3ca67eee461 (diff) |
Bump lots of changes
Diffstat (limited to 'web/nms.gathering.org/speedometer/d3-master/test/load.js')
-rw-r--r-- | web/nms.gathering.org/speedometer/d3-master/test/load.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/web/nms.gathering.org/speedometer/d3-master/test/load.js b/web/nms.gathering.org/speedometer/d3-master/test/load.js new file mode 100644 index 0000000..43ea239 --- /dev/null +++ b/web/nms.gathering.org/speedometer/d3-master/test/load.js @@ -0,0 +1,62 @@ +process.env.TZ = "America/Los_Angeles"; + +var smash = require("smash"), + jsdom = require("jsdom"); + +require("./XMLHttpRequest"); + +module.exports = function() { + var files = [].slice.call(arguments).map(function(d) { return "src/" + d; }), + expression = "d3", + sandbox = {console: console, Date: Date}; // so we can use deepEqual in tests + + files.unshift("test/start"); + + function topic() { + var callback = this.callback; + smash.load(files, expression, sandbox, function(error, result) { + if (error) console.trace(error.stack); + callback(error, result); + }); + } + + topic.expression = function(_) { + expression = _; + return topic; + }; + + topic.sandbox = function(_) { + sandbox = _; + return topic; + }; + + topic.document = function(_) { + var document = jsdom.jsdom(); + + // Monkey-patch createRange support to JSDOM. + document.createRange = function() { + return { + selectNode: function() {}, + createContextualFragment: jsdom.jsdom + }; + }; + + sandbox = { + console: console, + XMLHttpRequest: XMLHttpRequest, + document: document, + window: document.parentWindow, + setTimeout: setTimeout, + clearTimeout: clearTimeout, + Date: Date // so we can override Date.now in tests, and use deepEqual + }; + + return topic; + }; + + return topic; +}; + +process.on("uncaughtException", function(e) { + console.trace(e.stack); +}); |