2017-02-25 00:50:17 +01:00
|
|
|
/**
|
|
|
|
* TestRunner.js
|
|
|
|
*
|
|
|
|
* This is for actually running the tests in the test register.
|
|
|
|
*
|
2017-02-28 18:08:36 +01:00
|
|
|
* @author tlwr [toby@toby.codes]
|
2017-02-25 00:50:17 +01:00
|
|
|
* @copyright Crown Copyright 2017
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
2017-02-28 18:08:36 +01:00
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
TestRegister.runTests()
|
|
|
|
.then(function(results) {
|
|
|
|
results.forEach(function(testResult) {
|
2017-02-25 00:50:17 +01:00
|
|
|
|
|
|
|
if (typeof window.callPhantom === "function") {
|
2017-02-28 18:08:36 +01:00
|
|
|
// If we're running this in PhantomJS
|
|
|
|
window.callPhantom(
|
|
|
|
"testResult",
|
|
|
|
testResult
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// If we're just viewing this in a normal browser
|
|
|
|
var output = [
|
|
|
|
"----------",
|
|
|
|
testResult.test.name,
|
|
|
|
testResult.status,
|
|
|
|
testResult.output,
|
|
|
|
].join("<br>");
|
|
|
|
document.querySelector("main").innerHTML += output;
|
2017-02-25 00:50:17 +01:00
|
|
|
}
|
|
|
|
});
|
2017-02-28 18:08:36 +01:00
|
|
|
|
|
|
|
if (typeof window.callPhantom === "function") {
|
|
|
|
window.callPhantom("exit");
|
|
|
|
}
|
2017-02-25 00:50:17 +01:00
|
|
|
});
|
2017-02-28 18:08:36 +01:00
|
|
|
});
|