mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-12 05:55:02 +10:00
6a01207b6b
Adds ~1000 tests to bring the previously-untested packages and apps under coverage: - packages/utils — string, color, date, file, level, locale, sanitize, field, html, network-icons, rate-limit, url, url-security, monorepo, resume/patch, resume/docx/link-utils, style helpers (~97% on the testable utility files) - packages/ui — 28 component test files plus the use-controlled-state, use-mobile, use-confirm, use-prompt hooks (95% statements) - packages/pdf — shared template helpers (filtering, columns, picture, metrics, section-links, page-size, rich-text-html, section-title) - packages/schema — resumeDataSchema, page, templates, default - packages/fonts — expanded coverage on font helpers - packages/ai — resume sanitize and extraction template - packages/api — resume-access-policy - apps/web — error-message, locale, theme, pwa, dialogs/store, and the resume/move-item / section-actions / make-section-item helpers Adds jsdom polyfills (ResizeObserver, IntersectionObserver, scrollIntoView, matchMedia) and an explicit React Testing Library cleanup hook to vitest.setup.ts so portal- and overlay-based components work without per-test setup.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cn } from "./style";
|
|
|
|
describe("cn", () => {
|
|
it("joins simple class strings", () => {
|
|
expect(cn("a", "b", "c")).toBe("a b c");
|
|
});
|
|
|
|
it("filters out falsy values", () => {
|
|
expect(cn("a", null, undefined, false, "b", 0)).toBe("a b");
|
|
});
|
|
|
|
it("conditionally applies classes via object syntax", () => {
|
|
expect(cn({ a: true, b: false, c: true })).toBe("a c");
|
|
});
|
|
|
|
it("flattens arrays of inputs", () => {
|
|
expect(cn(["a", "b"], ["c"])).toBe("a b c");
|
|
});
|
|
|
|
it("merges conflicting tailwind classes (later wins)", () => {
|
|
expect(cn("p-4", "p-2")).toBe("p-2");
|
|
expect(cn("text-red-500", "text-blue-500")).toBe("text-blue-500");
|
|
});
|
|
|
|
it("preserves non-conflicting tailwind classes", () => {
|
|
expect(cn("text-red-500", "bg-white")).toContain("text-red-500");
|
|
expect(cn("text-red-500", "bg-white")).toContain("bg-white");
|
|
});
|
|
|
|
it("handles responsive variants distinctly from base classes", () => {
|
|
expect(cn("p-4", "md:p-2")).toBe("p-4 md:p-2");
|
|
});
|
|
|
|
it("returns empty string for no input", () => {
|
|
expect(cn()).toBe("");
|
|
});
|
|
|
|
it("returns empty string when all inputs are falsy", () => {
|
|
expect(cn(null, undefined, false)).toBe("");
|
|
});
|
|
|
|
it("merges twMerge group conflicts (e.g., flex-row vs flex-col)", () => {
|
|
expect(cn("flex-row", "flex-col")).toBe("flex-col");
|
|
});
|
|
});
|