-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.js
More file actions
68 lines (61 loc) · 2.06 KB
/
Copy pathsetup.js
File metadata and controls
68 lines (61 loc) · 2.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var jsdom = require("jsdom"),
fs = require("fs"),
reporter = require("./custom/reporter.js");
before(function (done) {
jsdom.env({
html: '',
resourceLoader: function (resource, callback) {
return callback(null,
fs.readFileSync("./public/" + resource.url.pathname, "utf-8"));
},
features: {},
done: function (errors, window) {
boot(window, done);
}
});
});
function boot(window, done) {
var loadJasmine = function load_jasmine() {
var jasmine = window.document.createElement("script");
jasmine.src = "jasmine/jasmine.js";
jasmine.onload = function () {
createJasmine(window);
loadSource();
};
window.document.body.appendChild(jasmine);
},
loadSource = function load_source() {
var source = window.document.createElement("script");
source.src = "src/calculator.js";
source.onload = function () {
loadSpecs();
};
window.document.body.appendChild(source);
},
loadSpecs = function load_specs() {
var specs = window.document.createElement("script");
specs.src = "spec/calculator.spec.js";
specs.onload = function () {
execute();
};
window.document.body.appendChild(specs);
},
execute = function execute() {
global.env.execute();
done();
};
loadJasmine();
};
function createJasmine(window) {
var jasmineRequire = window.jasmineRequire,
jasmine = jasmineRequire.core(jasmineRequire);
global.env = jasmine.getEnv();
var jasmineInterface = jasmineRequire.interface(jasmine, global.env);
global.reporter = new reporter();
global.env.addReporter(global.reporter);
extend(window, jasmineInterface);
}
function extend(destination, source) {
for (var property in source) destination[property] = source[property];
return destination;
}