- 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
+4
View File
@@ -18,6 +18,10 @@ button, input, textarea {
width: 100%;
}
input {
text-align: center;
}
h1 {
font-size: 12pt;
text-align: center;
+1
View File
@@ -9,6 +9,7 @@
</head>
<body>
<h1 id="descriptionLbl">Advanced HTTP test suite</h1>
<input value="idle" id="statusInput" readonly></input>
<textarea rows="16" cols="50" id="expectedTextarea">Click next to run first test.</textarea>
<textarea rows="16" cols="50" id="resultTextarea"></textarea>
<button id="nextBtn">Run next test</button>
+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];