import assert from "node:assert/strict"; import { dirname, join } from "node:path"; import { test } from "node:test"; import { fileURLToPath } from "node:url"; import * as ejs from "ejs"; const menu = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "views", "partials", "menu.ejs"); const render = (data: Record = {}): Promise => ejs.renderFile(menu, data); const flat = (s: string): string => s.replace(/>\s+<").replace(/\s+/g, " ").trim(); test("menu renders trigger, positioning, the item matrix and check groups", async () => { const html = flat(await render({ trigger: { icon: "i-cols", text: "Columns", label: "Column settings" }, align: "left", up: true, width: 240, items: [ { head: "Actions" }, { label: "Profile", icon: "i-user" }, // button (default), with icon { label: "Docs", href: "/docs" }, // link { sep: true }, { label: "Sign out", icon: "i-logout", danger: true }, { group: { legend: "Role", name: "role", control: "radio", options: [ { value: "", label: "Any role", checked: true }, { value: "admin", label: "Admin" }, ] } }, { group: { name: "col", options: [{ value: "name", label: "Name", checked: true }] } }, // checkbox default, no legend ], })); // Trigger: icon + text + aria-label; popover carries align/up classes + width. assert.match(html, /'); });