- added indicator for running tests

- validation function is triggered when test is finished
This commit is contained in:
Sefa Ilkimen
2017-10-23 16:54:34 +02:00
parent 15bf6281bc
commit 9655c89486
5 changed files with 111 additions and 23 deletions
+21
View File
@@ -1,6 +1,8 @@
const app = {
testIndex: -1,
lastResult: null,
initialize: function() {
document.getElementById('nextBtn').addEventListener('click', app.onNextBtnClick);
},
@@ -12,11 +14,27 @@ const app = {
},
reject: function(content) {
document.getElementById('statusInput').value = 'finished';
app.printResult('result - rejected', content);
app.lastResult = {
type: 'rejected',
data: content
};
},
resolve: function(content) {
document.getElementById('statusInput').value = 'finished';
app.printResult('result - resolved', content);
app.lastResult = {
type: 'resolved',
data: content
};
},
getResult: function(cb) {
cb(app.lastResult);
},
runTest: function(index) {
@@ -24,6 +42,7 @@ const app = {
const titleText = app.testIndex + ': ' + testDefinition.description;
const expectedText = 'expected - ' + testDefinition.expected;
document.getElementById('statusInput').value = 'running';
document.getElementById('expectedTextarea').value = expectedText;
document.getElementById('resultTextarea').value = '';
document.getElementById('descriptionLbl').innerText = titleText;
@@ -31,6 +50,8 @@ const app = {
},
onBeforeTest: function(testIndex, cb) {
app.lastResult = null;
if (hooks && hooks.onBeforeEachTest) {
return hooks.onBeforeEachTest(function() {
const testDefinition = tests[testIndex];