tailwind-class-merge
Version:
A utility function that combines `clsx` and `tailwind-merge` to ensure that a string of Tailwind CSS classnames are free of duplications and conflicts.
25 lines (24 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
describe("classMerge", () => {
it("should merge class names correctly", () => {
const result = (0, index_1.classMerge)("text-lg", "font-bold", "text-red-500");
expect(result).toBe("text-lg font-bold text-red-500");
});
it("should handle empty inputs", () => {
const result = (0, index_1.classMerge)();
expect(result).toBe("");
});
it("should merge class names with conflicting Tailwind utilities", () => {
const result = (0, index_1.classMerge)("text-lg", "text-xl", "text-red-500", "text-blue-500");
expect(result).toBe("text-xl text-blue-500");
});
it("should merge class names with conditional objects", () => {
const result = (0, index_1.classMerge)("text-lg", {
"font-bold": true,
"text-red-500": false,
});
expect(result).toBe("text-lg font-bold");
});
});