- Vitest multi-project setup (unit / integration / component) - Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL override), migrations applied per worker; production code untouched - Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme, marquee, media, portfolio helpers, plus architecture-rule tests - Integration: Prisma data layer, API routes, and all server actions - Component: UI primitives and form components (jsdom + Testing Library) - 371 tests passing
27 lines
723 B
TypeScript
27 lines
723 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
describe("cn", () => {
|
|
it("joins truthy class values", () => {
|
|
expect(cn("a", "b")).toBe("a b");
|
|
});
|
|
|
|
it("ignores falsey values", () => {
|
|
expect(cn("a", false, null, undefined, "", "b")).toBe("a b");
|
|
});
|
|
|
|
it("supports conditional object syntax", () => {
|
|
expect(cn("base", { active: true, hidden: false })).toBe("base active");
|
|
});
|
|
|
|
it("merges conflicting tailwind classes, last wins", () => {
|
|
expect(cn("px-2", "px-4")).toBe("px-4");
|
|
expect(cn("text-sm text-red-500", "text-lg")).toBe("text-red-500 text-lg");
|
|
});
|
|
|
|
it("flattens arrays", () => {
|
|
expect(cn(["a", "b"], "c")).toBe("a b c");
|
|
});
|
|
});
|