import { describe, expect, it } from "vitest";
import { SelectRootPropsSchema, SelectMeta } from "../../src/components/select/select.props";
import { ComboboxRootPropsSchema, ComboboxMeta } from "../../src/components/combobox/combobox.props";
import { DropdownMenuRootPropsSchema, DropdownMenuMeta } from "../../src/components/dropdown-menu/dropdown-menu.props";
import { ListboxRootPropsSchema, ListboxMeta } from "../../src/components/listbox/listbox.props";
import { SeparatorPropsSchema, SeparatorMeta } from "../../src/components/separator/separator.props";
import { PaginationRootPropsSchema, PaginationMeta } from "../../src/components/pagination/pagination.props";

describe("Collection component schemas", () => {
  it("Select validates", () => {
    const result = SelectRootPropsSchema.safeParse({ value: "opt1", placeholder: "Choose..." });
    expect(result.success).toBe(true);
  });

  it("Combobox validates", () => {
    const result = ComboboxRootPropsSchema.safeParse({ inputValue: "search", allowCustomValue: true });
    expect(result.success).toBe(true);
  });

  it("DropdownMenu validates", () => {
    const result = DropdownMenuRootPropsSchema.safeParse({ open: true });
    expect(result.success).toBe(true);
  });

  it("Listbox validates single and multiple", () => {
    const single = ListboxRootPropsSchema.safeParse({ value: "a" });
    const multi = ListboxRootPropsSchema.safeParse({ value: ["a", "b"], multiple: true });
    expect(single.success).toBe(true);
    expect(multi.success).toBe(true);
  });

  it("Separator validates orientation enum", () => {
    const valid = SeparatorPropsSchema.safeParse({ orientation: "vertical" });
    const invalid = SeparatorPropsSchema.safeParse({ orientation: "angled" });
    expect(valid.success).toBe(true);
    expect(invalid.success).toBe(false);
  });

  it("Pagination validates", () => {
    const result = PaginationRootPropsSchema.safeParse({ page: 3, count: 10, siblingCount: 2 });
    expect(result.success).toBe(true);
  });

  it("all Meta objects valid", () => {
    const metas = [SelectMeta, ComboboxMeta, DropdownMenuMeta, ListboxMeta, SeparatorMeta, PaginationMeta];
    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);
    }
  });
});
