mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-26 18:04:45 +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.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { getTemplateMetrics } from "./metrics";
|
|
|
|
describe("getTemplateMetrics", () => {
|
|
it("maps margins to page paddings", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 4, gapY: 6, marginX: 14, marginY: 12 });
|
|
expect(metrics.page.paddingHorizontal).toBe(14);
|
|
expect(metrics.page.paddingVertical).toBe(12);
|
|
});
|
|
|
|
it("uses marginY as headerGap and sectionGap", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 4, gapY: 6, marginX: 14, marginY: 20 });
|
|
expect(metrics.headerGap).toBe(20);
|
|
expect(metrics.sectionGap).toBe(20);
|
|
});
|
|
|
|
it("uses marginX as columnGap", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 4, gapY: 6, marginX: 30, marginY: 12 });
|
|
expect(metrics.columnGap).toBe(30);
|
|
});
|
|
|
|
it("preserves itemGapX and itemGapY directly from gapX/gapY", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 7, gapY: 9, marginX: 14, marginY: 12 });
|
|
expect(metrics.itemGapX).toBe(7);
|
|
expect(metrics.itemGapY).toBe(9);
|
|
});
|
|
|
|
it("provides gapX/gapY scaling functions", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 4, gapY: 6, marginX: 14, marginY: 12 });
|
|
expect(metrics.gapX(2)).toBe(8);
|
|
expect(metrics.gapY(3)).toBe(18);
|
|
});
|
|
|
|
it("scaling by 0.5 returns half-gap", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 10, gapY: 20, marginX: 14, marginY: 12 });
|
|
expect(metrics.gapX(0.5)).toBe(5);
|
|
expect(metrics.gapY(0.5)).toBe(10);
|
|
});
|
|
|
|
it("scaling by 0 returns 0", () => {
|
|
const metrics = getTemplateMetrics({ gapX: 4, gapY: 6, marginX: 14, marginY: 12 });
|
|
expect(metrics.gapX(0)).toBe(0);
|
|
expect(metrics.gapY(0)).toBe(0);
|
|
});
|
|
});
|