docs(tests): explain legacy canvas and workspace unit coverage
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
/**
|
||||
* 旧画布 CanvasElement 类体系的纯图片能力及图标搜索测试,与 headless component registry 的模型定义分开。
|
||||
* 只操作节点数据、几何和序列化,不挂载 renderer 或读取图片字节。
|
||||
*/
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { canvasReducer, decodeCanvas, emptyCanvas, makeCanvasNode } from "../src/lib/canvas.ts";
|
||||
@@ -5,6 +9,7 @@ import { CanvasElement, CardElement, PlainImageElement } from "../src/lib/canvas
|
||||
import { resizeFromPointer } from "../src/lib/canvas-geometry.ts";
|
||||
import { iconCatalog, iconsById, searchIcons } from "../src/components/canvas/icon-catalog.ts";
|
||||
|
||||
// PlainImageElement 继承通用变换但不继承 CardElement,比例缩放、名称和 src 可恢复,重命名可撤销。
|
||||
test("plain images inherit transforms without card connections and preserve source/name on restore", () => {
|
||||
const image = new PlainImageElement({ x: 0, y: 0 }, "", "data:image/png;base64,YQ==");
|
||||
assert(image instanceof CanvasElement); assert.equal(image instanceof CardElement, false);
|
||||
@@ -18,6 +23,7 @@ test("plain images inherit transforms without card connections and preserve sour
|
||||
assert.equal(canvasReducer(renamed, { type: "undo" }).present.nodes[0].data.title, "图片");
|
||||
});
|
||||
|
||||
// 纯图片不能作为卡片连线目标;删除连线后 javascript: src 仍必须被解码器拒绝。
|
||||
test("plain image sources are required and pure images cannot acquire card connections", () => {
|
||||
const image = makeCanvasNode("plain-image", { x: 0, y: 0 }, "data:image/png;base64,YQ==");
|
||||
const card = makeCanvasNode("text", { x: 300, y: 0 });
|
||||
@@ -27,6 +33,7 @@ test("plain image sources are required and pure images cannot acquire card conne
|
||||
assert.throws(() => decodeCanvas(JSON.stringify(document)));
|
||||
});
|
||||
|
||||
// 图标 ID 唯一并符合后端字符形状,中文类别与英文词可搜索;仅验证当前本地目录,不请求后端搜索。
|
||||
test("the complete Lucide catalog has unique backend-compatible identifiers and searchable names", () => {
|
||||
assert(iconCatalog.length > 2000);
|
||||
assert.equal(iconsById.size, iconCatalog.length);
|
||||
|
||||
Reference in New Issue
Block a user