26 lines
693 B
TypeScript
26 lines
693 B
TypeScript
|
|
import { describe, it, expect } from "vitest";
|
||
|
|
import { cn } from "./utils";
|
||
|
|
|
||
|
|
describe("cn", () => {
|
||
|
|
it("merges class names", () => {
|
||
|
|
expect(cn("foo", "bar")).toBe("foo bar");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("filters falsy values", () => {
|
||
|
|
expect(cn("foo", false, null, undefined, "", "bar")).toBe("foo bar");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("dedupes conflicting tailwind classes", () => {
|
||
|
|
// twMerge keeps the last conflicting utility
|
||
|
|
expect(cn("px-2", "px-4")).toBe("px-4");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("handles conditional class objects via clsx", () => {
|
||
|
|
expect(cn("base", { active: true, disabled: false })).toBe("base active");
|
||
|
|
});
|
||
|
|
|
||
|
|
it("returns empty string for no args", () => {
|
||
|
|
expect(cn()).toBe("");
|
||
|
|
});
|
||
|
|
});
|