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: {} }); 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({}, "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" } }); expect(label).toBe("Button — " + "😀".repeat(64) + "…"); expect(builderOutlineLabel(node({ label: '' }))).toContain(''); expect(builderOutlineLabel(node({ text: {}, label: "", title: "Product title" }))).toBe("content.button — Product title"); });