PettyUI/packages/core/tests/dialog.test.ts
Mats Bosson 168b5642d0 All components, schemas, tests, MCP, and showcase
- 51 headless Web Components (45 core + 6 animation)
- Shared helpers: emit(), part(), listen(), wireLabel(), initialValue()
- Zero `new CustomEvent` or `static #counter` — all use shared utils
- Zod schemas for all 44 core components
- MCP package with discover, inspect, compose, validate tools
- Showcase with Aperture Science theme, M3 Expressive motion
- 81 tests passing, TypeScript strict mode clean
- Signals (~500B), SPA router (~400B), zero dependencies
2026-03-31 21:42:29 +07:00

37 lines
1.1 KiB
TypeScript

import { describe, it, expect, beforeEach } from "vitest";
import { PettyDialog } from "../src/components/dialog/index";
import { h } from "./helpers";
describe("petty-dialog", () => {
let el: PettyDialog;
beforeEach(() => {
document.body.textContent = "";
el = document.createElement("petty-dialog") as PettyDialog;
const heading = h("h2", {}, "Title");
const dlg = document.createElement("dialog");
dlg.appendChild(heading);
el.appendChild(dlg);
document.body.appendChild(el);
});
it("registers the custom element", () => {
expect(customElements.get("petty-dialog")).toBe(PettyDialog);
});
it("links aria-labelledby to heading", () => {
const dlg = el.querySelector("dialog")!;
const heading = el.querySelector("h2")!;
expect(heading.id).not.toBe("");
expect(dlg.getAttribute("aria-labelledby")).toBe(heading.id);
});
it("exposes isOpen as false by default", () => {
expect(el.isOpen).toBe(false);
});
it("returns dialogElement", () => {
expect(el.dialogElement).toBeInstanceOf(HTMLDialogElement);
});
});