2014-10-31 16:49:07 +00:00
|
|
|
<!DOCTYPE html>
|
2014-10-30 23:04:38 +00:00
|
|
|
<html>
|
2014-10-31 00:24:30 +00:00
|
|
|
<head>
|
|
|
|
<link rel="stylesheet"
|
|
|
|
type="text/css"
|
|
|
|
href="platform/framework/test/lib/css/jasmine.css">
|
2014-11-07 03:53:26 +00:00
|
|
|
<script type="text/javascript"
|
|
|
|
src="platform/framework/lib/es6-promise-2.0.0.min.js">
|
|
|
|
</script>
|
2014-10-31 00:24:30 +00:00
|
|
|
<script type="text/javascript"
|
|
|
|
src="platform/framework/lib/require.js">
|
2014-10-30 23:04:38 +00:00
|
|
|
</script>
|
2014-10-31 00:24:30 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<script>
|
2014-11-07 03:53:26 +00:00
|
|
|
window.Promise = window.Promise || ES6Promise.Promise;
|
2014-10-31 00:24:30 +00:00
|
|
|
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'
|
|
|
|
},
|
|
|
|
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
|
2014-11-06 02:06:03 +00:00
|
|
|
try {
|
2014-11-05 22:10:46 +00:00
|
|
|
callback(JSON.parse(xhr.response));
|
2014-11-06 02:06:03 +00:00
|
|
|
} catch (e) {
|
2014-11-05 22:10:46 +00:00
|
|
|
// No suite defined, so no tests
|
|
|
|
callback([]);
|
|
|
|
}
|
2014-10-31 00:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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) {
|
2015-01-03 02:18:03 +00:00
|
|
|
var components = [],
|
|
|
|
configuration = { baseUrl: "" },
|
|
|
|
count = 0;
|
2014-10-31 00:24:30 +00:00
|
|
|
|
|
|
|
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) {
|
2015-01-03 02:18:03 +00:00
|
|
|
require.config(configuration);
|
2014-10-31 00:24:30 +00:00
|
|
|
runSpecs(components);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loadJSON(bundle + "/test/suite.json", addSpecs);
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:18:03 +00:00
|
|
|
// 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);
|
2014-10-31 00:24:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the ball rolling; load and run all test suites
|
|
|
|
loadJSON("bundles.json", runSuites);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
2014-10-30 23:04:38 +00:00
|
|
|
</html>
|