import { describe, expect, it } from "vitest"; import { TOOLCRAFT_BUILT_IN_CONTROL_TYPES } from "../contracts/component-contracts"; import { defineToolcraftCustomControlType } from "./custom-control-type"; describe("custom control type registration", () => { it("preserves the exact valid renderer key", () => { expect(defineToolcraftCustomControlType("glyphDensityEditor")).toBe("glyphDensityEditor"); }); it.each([...TOOLCRAFT_BUILT_IN_CONTROL_TYPES, "", " ", " name", "name ", null, 42, {}])( "rejects invalid names at the JavaScript boundary: %s", (name) => { expect(() => Reflect.apply(defineToolcraftCustomControlType, undefined, [name])).toThrow( "Custom control name must be nonempty, trimmed and not built-in.", ); }, ); });