not baad
This commit is contained in:
parent
4a8aff90b2
commit
6cef9a3abe
11 changed files with 1184 additions and 235 deletions
38
test.js
38
test.js
|
|
@ -11,23 +11,30 @@ import {
|
|||
validateGeneratedName,
|
||||
} from "./names.js";
|
||||
|
||||
const result = document.getElementById("result");
|
||||
const IS_BROWSER = typeof document !== "undefined";
|
||||
const result = IS_BROWSER ? document.getElementById("result") : { className: "", textContent: "" };
|
||||
const logLines = [];
|
||||
let failed = 0;
|
||||
|
||||
async function readLocalText(path) {
|
||||
if (IS_BROWSER) return fetch(path).then((response) => response.text());
|
||||
const { readFile } = await import("node:fs/promises");
|
||||
return readFile(new URL(path, import.meta.url), "utf8");
|
||||
}
|
||||
|
||||
const [namesSource, mapGeneratorSource, mapOutputSource, mapTerrainSource, rendererSource, appSource, mapPipelineSource, mapAdminStageSource, mapPatchSource, worldMapSource, municipalSource, testSource] = await Promise.all([
|
||||
fetch("./names.js").then((response) => response.text()),
|
||||
fetch("./mapGenerator.js").then((response) => response.text()),
|
||||
fetch("./mapOutput.js").then((response) => response.text()),
|
||||
fetch("./mapTerrain.js").then((response) => response.text()),
|
||||
fetch("./renderer.js").then((response) => response.text()),
|
||||
fetch("./app.js").then((response) => response.text()),
|
||||
fetch("./mapPipeline.js").then((response) => response.text()),
|
||||
fetch("./mapAdminStage.js").then((response) => response.text()),
|
||||
fetch("./mapPatch.js").then((response) => response.text()),
|
||||
fetch("./worldMap.js").then((response) => response.text()),
|
||||
fetch("./mapMunicipalCoherence.js").then((response) => response.text()),
|
||||
fetch("./test.js").then((response) => response.text()),
|
||||
readLocalText("./names.js"),
|
||||
readLocalText("./mapGenerator.js"),
|
||||
readLocalText("./mapOutput.js"),
|
||||
readLocalText("./mapTerrain.js"),
|
||||
readLocalText("./renderer.js"),
|
||||
readLocalText("./app.js"),
|
||||
readLocalText("./mapPipeline.js"),
|
||||
readLocalText("./mapAdminStage.js"),
|
||||
readLocalText("./mapPatch.js"),
|
||||
readLocalText("./worldMap.js"),
|
||||
readLocalText("./mapMunicipalCoherence.js"),
|
||||
readLocalText("./test.js"),
|
||||
]);
|
||||
|
||||
function assert(condition, message) {
|
||||
|
|
@ -1023,7 +1030,12 @@ try {
|
|||
|
||||
result.className = failed === 0 ? "ok" : "ng";
|
||||
result.textContent = `${failed === 0 ? "All tests passed." : `${failed} tests failed.`}\n\n${logLines.join("\n")}`;
|
||||
if (!IS_BROWSER) console.log(result.textContent);
|
||||
} catch (error) {
|
||||
result.className = "ng";
|
||||
result.textContent = String(error?.stack || error);
|
||||
if (!IS_BROWSER) {
|
||||
console.error(result.textContent);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue