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
+10 -4
View File
@@ -16,7 +16,7 @@ function fakeNode(attributes) {
};
}
function loadEditorFactory() {
async function loadEditorFactory() {
global.Element = class Element {};
global.document = {
currentScript: null,
@@ -30,12 +30,12 @@ function loadEditorFactory() {
clearTimeout,
requestAnimationFrame: (callback) => callback()
};
require("../static/cmap/cmap-racket-wiki.js");
await import("../static/cmap/cmap-racket-wiki.js");
return global.window.RacketWikiCmap;
}
test("the last selected concept determines target size and alignment", async () => {
const factory = loadEditorFactory();
const factory = await loadEditorFactory();
const map = {
onSelection() {},
onActivation() {},
@@ -53,6 +53,12 @@ test("the last selected concept determines target size and alignment", async ()
});
const second = editor.addItem({ id: 2, label: "Second", x: 80, y: 100, width: 120, height: 45 });
const third = editor.addItem({ id: 3, label: "Third", x: 250, y: 250, width: 200, height: 60 });
assert.equal(editor.conceptRepository().concept(first.conceptId).label, "First");
assert.equal(editor.conceptMapModel().item(first.id).conceptId, first.conceptId);
assert.equal("node" in editor.conceptRepository().concept(first.conceptId), false,
"repository concepts never contain drawing nodes");
assert.equal("node" in editor.conceptMapModel().item(first.id), false,
"map placements never contain drawing nodes");
const savedDocument = editor.toDocument();
assert.equal(
savedDocument.concepts.find((concept) => concept.id === first.conceptId).externalUrl,
@@ -141,7 +147,7 @@ test("the last selected concept determines target size and alignment", async ()
[Number(item.node.attr("width")), Number(item.node.attr("height"))]),
[[120, 45], [120, 45], [120, 45]]);
await new Promise((resolve) => setImmediate(resolve));
await new Promise((resolve) => setTimeout(resolve, 0));
assert.equal(editor.canUndo(), true, "layout commands participate in undo and autosave history");
assert.deepEqual(editor.toDocument().items.map((item) => [item.width, item.height]),
[[120, 45], [120, 45], [120, 45]]);