mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-11 21:45:04 +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.
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "./progress";
|
|
|
|
describe("Progress", () => {
|
|
it("renders with data-slot='progress'", () => {
|
|
render(<Progress data-testid="p" value={50} />);
|
|
expect(screen.getByTestId("p")).toHaveAttribute("data-slot", "progress");
|
|
});
|
|
|
|
it("auto-renders track and indicator children", () => {
|
|
const { container } = render(<Progress value={50} data-testid="p" />);
|
|
expect(container.querySelector("[data-slot=progress-track]")).toBeInTheDocument();
|
|
expect(container.querySelector("[data-slot=progress-indicator]")).toBeInTheDocument();
|
|
});
|
|
|
|
it("forwards value attribute via aria-valuenow", () => {
|
|
render(<Progress data-testid="p" value={75} />);
|
|
expect(screen.getByTestId("p")).toHaveAttribute("aria-valuenow", "75");
|
|
});
|
|
|
|
it("supports custom children rendered before the track", () => {
|
|
render(
|
|
<Progress data-testid="p" value={50}>
|
|
<ProgressLabel>My Progress</ProgressLabel>
|
|
</Progress>,
|
|
);
|
|
expect(screen.getByText("My Progress")).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("ProgressLabel", () => {
|
|
it("renders with data-slot='progress-label'", () => {
|
|
render(
|
|
<Progress value={50}>
|
|
<ProgressLabel>Label</ProgressLabel>
|
|
</Progress>,
|
|
);
|
|
expect(screen.getByText("Label")).toHaveAttribute("data-slot", "progress-label");
|
|
});
|
|
});
|
|
|
|
describe("ProgressValue", () => {
|
|
it("renders with data-slot='progress-value'", () => {
|
|
render(
|
|
<Progress value={50}>
|
|
<ProgressValue />
|
|
</Progress>,
|
|
);
|
|
// The value text is rendered by base-ui — just verify the slot exists
|
|
const { container } = render(
|
|
<Progress value={50}>
|
|
<ProgressValue data-testid="v" />
|
|
</Progress>,
|
|
);
|
|
expect(container.querySelector("[data-slot=progress-value]")).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("ProgressTrack and ProgressIndicator", () => {
|
|
it("can be rendered explicitly with custom classes", () => {
|
|
const { container } = render(
|
|
<Progress value={25}>
|
|
<ProgressTrack className="track-custom">
|
|
<ProgressIndicator className="ind-custom" />
|
|
</ProgressTrack>
|
|
</Progress>,
|
|
);
|
|
expect(container.querySelectorAll("[data-slot=progress-track]")).toHaveLength(2);
|
|
});
|
|
});
|