refactoring

This commit is contained in:
2026-09-02 08:38:03 +02:00
parent 649ff0d7c5
commit 38f255c1a4
48 changed files with 6998 additions and 5577 deletions
+33 -3
View File
@@ -2,9 +2,21 @@
const test = require("node:test");
const assert = require("node:assert/strict");
const {
buildBundle, validateBundle, preparedMapDocument, attachmentUrls, replaceAttachmentUrls
} = require("../static/js/cmap-interchange.js");
let buildBundle;
let validateBundle;
let preparedMapDocument;
let attachmentUrls;
let replaceAttachmentUrls;
test.before(async () => {
({
buildBundle,
validateBundle,
preparedMapDocument,
attachmentUrls,
replaceAttachmentUrls
} = await import("../static/js/wiki/cmap/interchange.js"));
});
const conceptId = "24d27086-9f8b-4b57-a7fb-47b513277555";
const childId = "53ef1cf3-c936-48f7-889a-ad644fab9321";
@@ -150,6 +162,24 @@ test("invalid connector endpoints and duplicate slugs are rejected", () => {
assert.throws(() => validateBundle(bundle), /unknown item[\s\S]*duplicated/);
});
test("bundle export omits connectors whose endpoint no longer exists", async () => {
const mapWithDanglingConnectors = structuredClone(root);
mapWithDanglingConnectors.document.connectors.push(
{ id: 2, sourceId: 10, targetId: 99 },
{ id: 3, sourceId: 98, targetId: 11 }
);
const bundle = await buildBundle({
rootMap: mapWithDanglingConnectors,
maxDepth: 0,
loadConceptMap: async () => { throw new Error("not loaded"); },
loadWikiPage: async (reference) => pages.get(reference),
loadAttachment
});
assert.deepEqual(bundle.cmaps[0].document.connectors, root.document.connectors);
});
test("external concept links only accept complete http or https URLs", () => {
const bundle = {
format: "racket-wiki-cmap-bundle", formatVersion: 1, rootCmapSlug: "map",