forked from NASA-AMMOS/openmct-mcws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
173 lines (153 loc) · 6.71 KB
/
test.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet"
type="text/css"
href="platform/framework/test/lib/css/jasmine.css">
<script type="text/javascript"
src="platform/framework/lib/require.js">
</script>
</head>
<body>
<script>
require(
{
paths: {
'jasmine': 'platform/framework/test/lib/jasmine',
'jasmine-html': 'platform/framework/test/lib/jasmine-html',
'blanket-jasmine': 'platform/framework/test/lib/blanket_jasmine',
'console-runner': 'platform/framework/test/lib/console-runner',
'lodash': 'bower_components/lodash/lodash'
},
shim: {
'jasmine': {
'exports': 'jasmine'
},
'jasmine-html': {
'exports': 'jasmine',
'deps': ['jasmine']
},
'console-runner': {
'exports': 'jasmine',
'deps': ['jasmine']
},
'blanket-jasmine': {
'exports': 'blanket',
'deps': ['jasmine']
}
}
},
[
'blanket-jasmine',
'jasmine-html',
'console-runner'
],
function () {
"use strict";
// Utility function; load a JSON definition
function loadJSON(file, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", file);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) { // DONE
try {
callback(JSON.parse(xhr.response));
} catch (e) {
// No suite defined, so no tests
callback([]);
}
}
}
xhr.send();
}
// Run Jasmine upon full declared suite.
// Called after all tests loaded.
function runJasmine() {
var jasmineEnv = jasmine.getEnv(),
htmlReporter,
titleReporter;
jasmineEnv.updateInterval = 250;
htmlReporter = new jasmine.HtmlReporter();
//https://github.com/jcarver989/phantom-jasmine/issues/2
window.console_reporter = new jasmine.ConsoleReporter();
titleReporter = new jasmine.Reporter();
titleReporter.reportRunnerResults = function (runner) {
document.title = runner.results().passed() ?
"PASSING" : "FAILING";
};
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.addReporter(new jasmine.BlanketReporter());
jasmineEnv.addReporter(window.console_reporter);
jasmineEnv.addReporter(titleReporter);
jasmineEnv.specFilter = function (spec) {
return htmlReporter.specFilter(spec);
};
jasmineEnv.currentRunner().execute();
}
function lookupSource(component) {
return component.src;
}
function lookupSpec(component) {
return component.spec;
}
// Run a full list of specs.
// Should be done after loading and path-correcting all specs
function runSpecs(components) {
blanket.options({'filter': components.map(lookupSource)});
require(components.map(lookupSpec), runJasmine);
}
// Run all test suites contained in all bundles
function runSuites(bundles) {
var components = [],
configuration = { baseUrl: "" },
count = 0;
function addSuite(bundle) {
function fixPath(name) {
return {
spec: bundle + "/test/" + name + "Spec",
src: bundle + "/src/" + name
};
}
function addSpecs(suiteSpecs) {
components = components.concat(suiteSpecs.map(fixPath));
count += 1;
if (count === bundles.length) {
require.config(configuration);
runSpecs(components);
}
}
loadJSON(bundle + "/test/suite.json", addSpecs);
}
// Some AMD modules are configured in bundle.json files,
// so those need to be read and a require definition built
function readConfig(bundle, definition) {
var lib = bundle.libraries || "lib",
bundleConfig = definition.configuration || {};
// Merge in paths
Object.keys(bundleConfig.paths || {}).forEach(function (path) {
configuration.paths = configuration.paths || {};
configuration.paths[path] =
bundle + "/" + lib + "/" + bundleConfig.paths[path];
});
// Merge in shims
Object.keys(bundleConfig.shim || {}).forEach(function (shim) {
configuration.shim = configuration.shim || {};
configuration.shim[shim] = bundleConfig.shim[shim];
});
}
function addBundle(bundle) {
function readConfigAndContinue(definition) {
readConfig(bundle, definition);
addSuite(bundle);
}
loadJSON(bundle + "/bundle.json", readConfigAndContinue);
}
bundles.forEach(addBundle);
}
// Set the ball rolling; load and run all test suites
loadJSON("bundles.json", runSuites);
}
);
</script>
</body>
</html>