import { describe, expect, test } from "bun:test"; import { isValidTextStyle, measureTextLayer, type TextLayer } from "./text-layer"; const layer: TextLayer = { id: "text-1", type: "text", name: "Title", visible: true, locked: false, opacity: 1, transform: { position: { x: 10, y: 20 }, scale: { x: 1, y: 1 }, rotation: 0 }, content: "Hello\nWorld", style: { fontFamily: "Arial", fontSize: 20, fontWeight: 400, fontStyle: "normal", color: "#ffffff", alignment: "left", lineHeight: 1.25 } }; describe("text layer metrics", () => { test("uses deterministic multiline bounds", () => expect(measureTextLayer(layer)).toEqual({ w: 54, h: 50 })); test("validates the closed built-in typography policy", () => { expect(isValidTextStyle(layer.style)).toBeTrue(); expect(isValidTextStyle({ ...layer.style, fontFamily: "Remote Font" as never })).toBeFalse(); expect(isValidTextStyle({ ...layer.style, color: "red" })).toBeFalse(); }); });