|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | + |
| 3 | +import { cn } from "./cn"; |
| 4 | + |
| 5 | +describe("cn", () => { |
| 6 | + it.each([ |
| 7 | + [["p-2", "p-4"], "p-4"], |
| 8 | + [["px-2 py-1", "px-4"], "py-1 px-4"], |
| 9 | + [["text-kumo-default", "text-kumo-subtle"], "text-kumo-subtle"], |
| 10 | + [["bg-kumo-base", "bg-kumo-elevated"], "bg-kumo-elevated"], |
| 11 | + [["border-kumo-line", "border-kumo-strong"], "border-kumo-strong"], |
| 12 | + [["hover:bg-kumo-base", "hover:bg-kumo-elevated"], "hover:bg-kumo-elevated"], |
| 13 | + [["sm:p-2", "sm:p-4", "md:p-6"], "sm:p-4 md:p-6"], |
| 14 | + [ |
| 15 | + ["data-[state=open]:bg-kumo-base", "data-[state=open]:bg-kumo-elevated"], |
| 16 | + "data-[state=open]:bg-kumo-elevated", |
| 17 | + ], |
| 18 | + [["rounded-[10px]", "rounded-[12px]"], "rounded-[12px]"], |
| 19 | + [["!p-2", "p-4"], "!p-2 p-4"], |
| 20 | + [["p-2", "!p-4"], "p-2 !p-4"], |
| 21 | + [["base", false, null, undefined, { active: true, disabled: false }], "base active"], |
| 22 | + [[["flex", ["gap-2", "gap-4"]]], "flex gap-4"], |
| 23 | + ])("merges classes without changing expected output for case %#", (inputs, expected) => { |
| 24 | + expect(cn(...inputs)).toBe(expected); |
| 25 | + }); |
| 26 | +}); |
0 commit comments