import { describe, expect, it } from "vitest";
import { ButtonPropsSchema, ButtonMeta } from "../../src/components/button/button.props";
import { BadgeMeta } from "../../src/components/badge/badge.props";
import { AlertMeta } from "../../src/components/alert/alert.props";
import { SkeletonMeta } from "../../src/components/skeleton/skeleton.props";
import { LinkPropsSchema, LinkMeta } from "../../src/components/link/link.props";
import { TogglePropsSchema, ToggleMeta } from "../../src/components/toggle/toggle.props";
import { ProgressRootPropsSchema, ProgressMeta } from "../../src/components/progress/progress.props";

describe("Simple component schemas", () => {
  it("Button schema validates", () => {
    const validBtn = ButtonPropsSchema.safeParse({ type: "submit" });
    const invalidBtn = ButtonPropsSchema.safeParse({ type: "invalid" });
    expect(validBtn.success).toBe(true);
    expect(invalidBtn.success).toBe(false);
  });

  it("Link schema validates", () => {
    const result = LinkPropsSchema.safeParse({ href: "/about", external: true });
    expect(result.success).toBe(true);
  });

  it("Toggle schema validates", () => {
    const result = TogglePropsSchema.safeParse({ pressed: true, disabled: false });
    expect(result.success).toBe(true);
  });

  it("Progress schema validates", () => {
    const result = ProgressRootPropsSchema.safeParse({ value: 50, max: 100 });
    expect(result.success).toBe(true);
  });

  it("all Meta objects have required fields", () => {
    const metas = [ButtonMeta, BadgeMeta, AlertMeta, SkeletonMeta, LinkMeta, ToggleMeta, ProgressMeta];
    for (const meta of metas) {
      expect(meta.name).toBeTruthy();
      expect(meta.description).toBeTruthy();
      expect(meta.parts.length).toBeGreaterThan(0);
      expect(meta.requiredParts.length).toBeGreaterThan(0);
    }
  });
});
