46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { handleInspect } from "../../src/tools/inspect.js";
|
|
import { ComponentRegistry } from "../../src/registry.js";
|
|
|
|
describe("pettyui.inspect", () => {
|
|
const registry = new ComponentRegistry();
|
|
|
|
it("returns full component info", () => {
|
|
const result = handleInspect(registry, { component: "Dialog" });
|
|
expect(result).not.toBeNull();
|
|
expect(result?.name).toBe("Dialog");
|
|
expect(result?.parts).toContain("Root");
|
|
expect(result?.parts).toContain("Content");
|
|
expect(result?.exportPath).toBe("pettyui/dialog");
|
|
expect(typeof result?.description).toBe("string");
|
|
expect(result?.description.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("includes JSON schema for props", () => {
|
|
const result = handleInspect(registry, { component: "Dialog" });
|
|
expect(result).not.toBeNull();
|
|
expect(result?.props).toBeDefined();
|
|
const dialogRoot = result?.props["dialogRoot"] as { type?: string } | undefined;
|
|
expect(dialogRoot).toBeDefined();
|
|
expect(dialogRoot?.type).toBe("object");
|
|
});
|
|
|
|
it("includes minimal example", () => {
|
|
const result = handleInspect(registry, { component: "Dialog" });
|
|
expect(result).not.toBeNull();
|
|
expect(result?.example).toContain("Dialog");
|
|
expect(result?.example).toContain('from "pettyui/dialog"');
|
|
});
|
|
|
|
it("returns null for unknown component", () => {
|
|
const result = handleInspect(registry, { component: "FakeComponent" });
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it("is case-insensitive", () => {
|
|
const result = handleInspect(registry, { component: "dialog" });
|
|
expect(result).not.toBeNull();
|
|
expect(result?.name).toBe("Dialog");
|
|
});
|
|
});
|