mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-14 23:07:01 +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.
62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "./button-group";
|
|
|
|
describe("ButtonGroup", () => {
|
|
it("renders a fieldset with data-slot='button-group'", () => {
|
|
render(<ButtonGroup data-testid="g" />);
|
|
const g = screen.getByTestId("g");
|
|
expect(g.tagName).toBe("FIELDSET");
|
|
expect(g).toHaveAttribute("data-slot", "button-group");
|
|
});
|
|
|
|
it("respects horizontal orientation (default)", () => {
|
|
render(<ButtonGroup data-testid="g" orientation="horizontal" />);
|
|
expect(screen.getByTestId("g")).toHaveAttribute("data-orientation", "horizontal");
|
|
});
|
|
|
|
it("respects vertical orientation", () => {
|
|
render(<ButtonGroup data-testid="g" orientation="vertical" />);
|
|
expect(screen.getByTestId("g")).toHaveAttribute("data-orientation", "vertical");
|
|
});
|
|
|
|
it("merges custom className", () => {
|
|
render(<ButtonGroup data-testid="g" className="my-custom" />);
|
|
expect(screen.getByTestId("g")).toHaveClass("my-custom");
|
|
});
|
|
});
|
|
|
|
describe("ButtonGroupText", () => {
|
|
it("renders content inside a div by default", () => {
|
|
render(<ButtonGroupText>Hello</ButtonGroupText>);
|
|
expect(screen.getByText("Hello").tagName).toBe("DIV");
|
|
});
|
|
|
|
it("merges custom className", () => {
|
|
render(<ButtonGroupText className="my-class">x</ButtonGroupText>);
|
|
expect(screen.getByText("x")).toHaveClass("my-class");
|
|
});
|
|
|
|
it("supports custom render function", () => {
|
|
render(<ButtonGroupText render={(props) => <span {...props} />}>label</ButtonGroupText>);
|
|
expect(screen.getByText("label").tagName).toBe("SPAN");
|
|
});
|
|
});
|
|
|
|
describe("ButtonGroupSeparator", () => {
|
|
it("defaults to vertical orientation", () => {
|
|
render(<ButtonGroupSeparator data-testid="sep" />);
|
|
expect(screen.getByTestId("sep")).toHaveAttribute("data-orientation", "vertical");
|
|
});
|
|
|
|
it("supports horizontal orientation", () => {
|
|
render(<ButtonGroupSeparator data-testid="sep" orientation="horizontal" />);
|
|
expect(screen.getByTestId("sep")).toHaveAttribute("data-orientation", "horizontal");
|
|
});
|
|
|
|
it("uses data-slot='button-group-separator'", () => {
|
|
render(<ButtonGroupSeparator data-testid="sep" />);
|
|
expect(screen.getByTestId("sep")).toHaveAttribute("data-slot", "button-group-separator");
|
|
});
|
|
});
|