mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
test: add unit and component tests across the monorepo
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.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createUrl } from "./url";
|
||||
|
||||
describe("createUrl", () => {
|
||||
it("returns empty url and label when no url provided", () => {
|
||||
expect(createUrl()).toEqual({ url: "", label: "" });
|
||||
});
|
||||
|
||||
it("returns empty pair when url is empty string (falsy)", () => {
|
||||
expect(createUrl("")).toEqual({ url: "", label: "" });
|
||||
});
|
||||
|
||||
it("uses url as label when no label provided", () => {
|
||||
expect(createUrl("https://example.com")).toEqual({
|
||||
url: "https://example.com",
|
||||
label: "https://example.com",
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves provided label", () => {
|
||||
expect(createUrl("https://example.com", "Example")).toEqual({
|
||||
url: "https://example.com",
|
||||
label: "Example",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to url when label is empty string", () => {
|
||||
expect(createUrl("https://example.com", "")).toEqual({
|
||||
url: "https://example.com",
|
||||
label: "https://example.com",
|
||||
});
|
||||
});
|
||||
|
||||
it("does not validate the url format (caller's responsibility)", () => {
|
||||
expect(createUrl("not-a-url", "Label")).toEqual({
|
||||
url: "not-a-url",
|
||||
label: "Label",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user