mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-13 22:37:14 +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.
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { templateSchema } from "./templates";
|
|
|
|
describe("templateSchema", () => {
|
|
it("accepts known template names", () => {
|
|
const validTemplates = [
|
|
"azurill",
|
|
"bronzor",
|
|
"chikorita",
|
|
"ditgar",
|
|
"ditto",
|
|
"gengar",
|
|
"glalie",
|
|
"kakuna",
|
|
"lapras",
|
|
"leafish",
|
|
"meowth",
|
|
"onyx",
|
|
"pikachu",
|
|
"rhyhorn",
|
|
];
|
|
for (const t of validTemplates) {
|
|
expect(templateSchema.safeParse(t).success).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("rejects unknown template names", () => {
|
|
expect(templateSchema.safeParse("unknown").success).toBe(false);
|
|
expect(templateSchema.safeParse("").success).toBe(false);
|
|
expect(templateSchema.safeParse("ONYX").success).toBe(false); // case-sensitive
|
|
});
|
|
|
|
it("rejects non-string values", () => {
|
|
expect(templateSchema.safeParse(null).success).toBe(false);
|
|
expect(templateSchema.safeParse(undefined).success).toBe(false);
|
|
expect(templateSchema.safeParse(42).success).toBe(false);
|
|
});
|
|
|
|
it("returns the exact value for a valid template", () => {
|
|
const result = templateSchema.safeParse("onyx");
|
|
expect(result.success).toBe(true);
|
|
if (result.success) {
|
|
expect(result.data).toBe("onyx");
|
|
}
|
|
});
|
|
|
|
it("includes 14 templates", () => {
|
|
const validTemplates = templateSchema.options;
|
|
expect(validTemplates).toHaveLength(14);
|
|
});
|
|
});
|