feat: release design system engine, studio and component contracts
This commit is contained in:
1 parent
ff1065fb27
commit
3943b946d6
693 files changed
+175546
-3894
No files matched your search
@@ -2,19 +2,34 @@ import { expect, test } from "bun:test";
|
||||
import type { BlockNode } from "@wrnexus/blocks";
|
||||
import { builderOutlineLabel } from "../src/outline.ts";
|
||||
|
||||
const node = (props: BlockNode["props"], type = "content.button"): BlockNode => ({ id: "n", type, version: 1, props, styles: {}, slots: {} });
|
||||
const node = (props: BlockNode["props"], type = "content.button"): BlockNode => ({
|
||||
id: "n",
|
||||
type,
|
||||
version: 1,
|
||||
props,
|
||||
styles: {},
|
||||
slots: {},
|
||||
});
|
||||
|
||||
test("outline uses registered names and distinguishes content without mutating it", () => {
|
||||
const block = node({ label: " Buy\n now " });
|
||||
expect(builderOutlineLabel(block, { name: { fallback: "Button" } })).toBe("Button — Buy now");
|
||||
expect(block.props.label).toBe(" Buy\n now ");
|
||||
expect(builderOutlineLabel(node({ width: "35%" }, "layout.column"), { name: { fallback: "Column" } })).toBe("Column — 35%");
|
||||
expect(
|
||||
builderOutlineLabel(node({ width: "35%" }, "layout.column"), { name: { fallback: "Column" } }),
|
||||
).toBe("Column — 35%");
|
||||
expect(builderOutlineLabel(node({}, "custom.unknown"))).toBe("custom.unknown");
|
||||
});
|
||||
|
||||
test("outline bounds Unicode snippets and treats content as plain text", () => {
|
||||
const label = builderOutlineLabel(node({ label: "😀".repeat(65) }), { name: { fallback: "Button" } });
|
||||
const label = builderOutlineLabel(node({ label: "😀".repeat(65) }), {
|
||||
name: { fallback: "Button" },
|
||||
});
|
||||
expect(label).toBe("Button — " + "😀".repeat(64) + "…");
|
||||
expect(builderOutlineLabel(node({ label: '<img onerror="bad">' }))).toContain('<img onerror="bad">');
|
||||
expect(builderOutlineLabel(node({ text: {}, label: "", title: "Product title" }))).toBe("content.button — Product title");
|
||||
expect(builderOutlineLabel(node({ label: '<img onerror="bad">' }))).toContain(
|
||||
'<img onerror="bad">',
|
||||
);
|
||||
expect(builderOutlineLabel(node({ text: {}, label: "", title: "Product title" }))).toBe(
|
||||
"content.button — Product title",
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user