import { describe, expect, it } from "vitest";

import {
  badgeClass,
  buttonClass,
  cn,
  focusRing,
  inputClass,
  overlayScrim,
  proseBody,
  segmentedClass,
  statusNoteClass,
} from "./variants";

describe("ui variants", () => {
  it("joins classes without falsey values", () => {
    expect(cn("a", false, undefined, null, "b")).toBe("a b");
  });

  it("builds stable primary button classes", () => {
    const klass = buttonClass({ variant: "primary", size: "sm" });

    expect(klass).toContain("bg-cinnabar");
    expect(klass).toContain("px-3");
    expect(klass).toContain("focus-visible:ring-2");
  });

  it("keeps warning badges readable on the paper background", () => {
    const klass = badgeClass({ variant: "warning" });

    expect(klass).toContain("bg-overdue/10");
    expect(klass).toContain("text-ink");
  });

  it("marks invalid inputs with conflict styling", () => {
    const klass = inputClass({ state: "error" });

    expect(klass).toContain("border-conflict");
    expect(klass).toContain("focus-visible:ring-conflict/25");
  });

  it("gives warning status notes a non-color icon slot friendly shell", () => {
    const klass = statusNoteClass({ variant: "warning" });

    expect(klass).toContain("border-overdue");
    expect(klass).toContain("px-3");
  });

  it("builds segmented control chrome", () => {
    const klass = segmentedClass();

    expect(klass).toContain("inline-flex");
    expect(klass).toContain("border-line");
  });

  it("shares the cinnabar focus ring with the button base", () => {
    expect(focusRing).toContain("focus-visible:ring-2");
    expect(focusRing).toContain("focus-visible:ring-cinnabar/35");
    expect(buttonClass({ variant: "primary" })).toContain(focusRing);
  });

  it("renders manuscript body as serif 18px with airy leading", () => {
    expect(proseBody).toContain("font-serif");
    expect(proseBody).toContain("text-[18px]");
    expect(proseBody).toContain("leading-[1.9]");
  });

  it("provides a full-screen overlay scrim below dialog chrome", () => {
    expect(overlayScrim).toContain("fixed");
    expect(overlayScrim).toContain("inset-0");
    expect(overlayScrim).toContain("z-40");
  });
});
