Centralises all Dialog prop interfaces and schemas in dialog.props.ts. Adds DialogRootPropsSchema, DialogContentPropsSchema, and DialogMeta for AI/MCP discovery. Sub-components now import types from the shared file.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
DialogRootPropsSchema,
|
|
DialogContentPropsSchema,
|
|
DialogMeta,
|
|
} from "../../../src/components/dialog/dialog.props";
|
|
|
|
describe("Dialog Zod schemas", () => {
|
|
it("validates correct root props", () => {
|
|
const result = DialogRootPropsSchema.safeParse({ open: true, modal: false });
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("validates empty root props (all optional)", () => {
|
|
const result = DialogRootPropsSchema.safeParse({});
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("rejects invalid root props", () => {
|
|
const result = DialogRootPropsSchema.safeParse({ open: "yes" });
|
|
expect(result.success).toBe(false);
|
|
});
|
|
|
|
it("validates content props", () => {
|
|
const result = DialogContentPropsSchema.safeParse({ forceMount: true });
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("exposes meta with required parts", () => {
|
|
expect(DialogMeta.name).toBe("Dialog");
|
|
expect(DialogMeta.parts).toContain("Root");
|
|
expect(DialogMeta.parts).toContain("Content");
|
|
expect(DialogMeta.parts).toContain("Title");
|
|
expect(DialogMeta.requiredParts).toContain("Root");
|
|
expect(DialogMeta.requiredParts).toContain("Content");
|
|
expect(DialogMeta.requiredParts).toContain("Title");
|
|
});
|
|
|
|
it("schema has descriptions on all fields", () => {
|
|
const shape = DialogRootPropsSchema.shape;
|
|
expect(shape.open.description).toBeDefined();
|
|
expect(shape.modal.description).toBeDefined();
|
|
});
|
|
});
|