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
|
import { runTests } from "./driver.js";
class AssertionError extends Error {}
const panel = document.querySelector("#panel");
const err = s => panel.innerHTML += s;
const assert = {
equal: (given, expected) => {
if (given !== expected) {
throw new AssertionError(
`given ${given}; expected ${expected}`
);
}
},
deepEqual: (x, y) => {
},
};
// FIXME
const escape = s => s;
const red = s => `<span class="red" >${escape(s)}</span>`;
const green = s => `<span class="green" >${escape(s)}</span>`;
const yellow = s => `<span class="yellow">${escape(s)}</span>`;
const conf = {
err,
assert,
colors: {
red,
green,
yellow,
},
};
const TEST_PATHS = [
"tests/papo.js",
"tests/sw.js",
];
export const main = (paths = TEST_PATHS) => {
document.addEventListener("DOMContentLoaded", async _ => {
for (const path of paths) {
const module = await import("../" + path);
conf.err(path + "\n");
await runTests(conf, module.allTests);
conf.err("\n");
}
});
};
|