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 => `${escape(s)}`;
const green = s => `${escape(s)}`;
const yellow = s => `${escape(s)}`;
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");
}
});
};