-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
77 lines (73 loc) · 2.63 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
<!DOCTYPE html>
<html>
<head>
<script src="dateParser.js"></script>
<script src="dateParser.tests.js"></script>
<script>
var addCell = function(tr, text) {
var td = tr.insertCell();
td.textContent = text;
};
function run() {
var resultTable = document.getElementById("resultTable");
var index = 0;
var results = T.runTests({
onTestCompleted: function(results) {
for(let result of results) {
var tr = resultTable.insertRow();
tr.classList.add(result.status);
addCell(tr, ++index);
addCell(tr, result.name);
addCell(tr, result["case"][0]);
addCell(tr, result["case"][1]);
addCell(tr, result.actual);
addCell(tr, result.status);
addCell(tr, (result.error && result.error.message) || "");
}
},
onAllTestsCompleted: function(results) {
const total = results.length;
const passed = results.filter(r => r.status === "pass").length;
const failed = results.filter(r => r.status === "fail").length;
const summaryLine = document.getElementById("summaryLine");
summaryLine.textContent = `Total: ${total}, Passed: ${passed}, Failed: ${failed}`;
}
});
console.log(results);
}
</script>
<style>
body {
font-family: monospace;
}
.pass {
background-color: palegreen;
}
.fail {
background-color: pink;
}
#resultTable {
width: 100%;
}
#summaryLine {
margin: 1em;
font-weight: bold;
}
</style>
</head>
<body onload="javascript: run()">
<div id="summaryLine">
</div>
<table id="resultTable">
<tr>
<th>#</th>
<th>Test</th>
<th>Input</th>
<th>Expected</th>
<th>Actual</th>
<th>Status</th>
<th>Error</th>
</tr>
<table>
</body>
</html>