import { expect, test } from "bun:test"; import { readFile } from "node:fs/promises"; import { join } from "node:path"; import { parse } from "@wrnexus/syntax"; const componentPath = join(import.meta.dir, "../components/Captcha.wrn"); test("Captcha.wrn parses and exposes the full public contract", async () => { const source = await readFile(componentPath, "utf8"); const ast = parse(source); expect(ast.kind).toBe("component"); expect(ast.name).toBe("Captcha"); for (const prop of [ "provider", "siteKey", "type", "action", "presentation", "difficulty", "disturbance", "imageStyle", "allowedStyles", "excludedStyles", "randomizeStyle", "size", "color", "class", "showListen", "resetOnError", ]) { expect(source).toContain(`${prop} =`); } for (const event of [ "ready", "challenge", "input", "verify", "success", "failure", "expired", "refresh", "audioStart", "audioEnd", "error", ]) { expect(source).toContain(`@event ${event} = function`); } expect(source).toContain("data-captcha-disturbance='{disturbance}'"); expect(source).toContain("data-captcha-image-style='{imageStyle}'"); expect(source).toContain("data-captcha-allowed-styles='{allowedStyles}'"); expect(source).toContain("data-captcha-excluded-styles='{excludedStyles}'"); expect(source).toContain("data-captcha-randomize-style='{randomizeStyle}'"); expect(source).toContain("data-captcha-show-listen='{showListen}'"); expect(source).toContain("data-captcha-reset-on-error='{resetOnError}'"); expect(source).toContain("data-captcha-not-robot-button"); expect(source).toContain("data-[captcha-size=compact]"); expect(source).toContain("data-[captcha-size=compact]:max-w-xs"); expect(source).toContain("group-data-[captcha-size=compact]/captcha:max-h-24"); expect(source).toContain("group-data-[captcha-size=compact]/captcha:h-8"); expect(source).toContain("group-data-[captcha-size=compact]/captcha:hidden"); expect(source).toContain("[data-captcha-footer]"); expect(source).toContain("display: contents"); expect(source).toContain("order: -1"); expect(source).toContain("data-[captcha-size=big]"); expect(source).toContain("{...attrs}"); expect(source).toContain("--wrn-"); expect(source).not.toMatch(/=\{/); expect(source).toContain('data-wrnexus-runtime="captcha"'); expect(source).not.toContain("