2026-06-04 15:16:53 -04:00
|
|
|
import { describe, it, expect } from "vitest";
|
2026-07-19 12:29:52 -05:00
|
|
|
import { cn } from "../../lib/utils.js";
|
2026-06-04 15:16:53 -04:00
|
|
|
|
|
|
|
|
describe("cn", () => {
|
|
|
|
|
it("joins class names", () => {
|
|
|
|
|
expect(cn("a", "b")).toBe("a b");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("drops falsy values", () => {
|
|
|
|
|
expect(cn("a", false, null, undefined, "b")).toBe("a b");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("merges conflicting tailwind classes, keeping the last", () => {
|
|
|
|
|
expect(cn("p-2", "p-4")).toBe("p-4");
|
|
|
|
|
expect(cn("text-red-500", "text-blue-500")).toBe("text-blue-500");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("supports conditional object syntax", () => {
|
|
|
|
|
expect(cn("base", { active: true, hidden: false })).toBe("base active");
|
|
|
|
|
});
|
|
|
|
|
});
|