Initialize Compose Launcher source and deployment
This commit is contained in:
commit
12a8c24441
77 files changed
+9594
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { runInNewContext } from "node:vm";
|
||||
import { normalizeLayout, validate } from "./src/layout.ts";
|
||||
|
||||
const fixtures = JSON.parse(readFileSync(new URL("../docs/layout-cases.json", import.meta.url), "utf8"));
|
||||
const offline = readFileSync(new URL("./canvas.html", import.meta.url), "utf8");
|
||||
const offlineFunction = name => {
|
||||
const start = offline.indexOf("function " + name + "(");
|
||||
const end = offline.indexOf("\n}", start) + 2;
|
||||
assert.ok(start >= 0 && end > start, name);
|
||||
return offline.slice(start, end);
|
||||
};
|
||||
|
||||
for (const { name, accepted, layout } of fixtures) {
|
||||
let editorAccepted;
|
||||
try {
|
||||
editorAccepted = !validate(normalizeLayout(layout)).some(issue => issue.level === "error");
|
||||
} catch {
|
||||
editorAccepted = false;
|
||||
}
|
||||
assert.equal(editorAccepted, accepted, "Vue editor: " + name);
|
||||
|
||||
const offlineAccepted = runInNewContext(`
|
||||
let state, activePage, selectedId;
|
||||
function pushHistory() {}
|
||||
function syncControls() {}
|
||||
function fitCanvas() {}
|
||||
function render() {}
|
||||
${offlineFunction("importLayout")}
|
||||
${offlineFunction("validate")}
|
||||
try {
|
||||
importLayout(layout);
|
||||
validate().errors === 0;
|
||||
} catch {
|
||||
false;
|
||||
}
|
||||
`, { layout });
|
||||
assert.equal(offlineAccepted, accepted, "Offline editor: " + name);
|
||||
}
|
||||
console.log(`${fixtures.length} shared cases passed in both editors`);
|
||||
Reference in new issue
Block a user