fix(cv): restore distinct responsive templates

This commit is contained in:
cesnimda
2026-09-01 08:54:03 +02:00
parent 9252e43ad4
commit c8b4c33acd
8 changed files with 161 additions and 23 deletions
+38 -1
View File
@@ -1,4 +1,4 @@
import { getCvPageCount, getCvPageMetrics, moveItem, normalizeCvLanguage, wrapSelection } from "./cvBuilder";
import { applyCvTheme, getCvPageCount, getCvPageMetrics, getCvPreviewFitZoom, moveItem, normalizeCvLanguage, wrapSelection } from "./cvBuilder";
describe("moveItem", () => {
test("moves an item forward", () => {
@@ -59,4 +59,41 @@ describe("CV language compatibility", () => {
expect(normalizeCvLanguage("nb-NO")).toBe("nb-NO");
expect(normalizeCvLanguage("en")).toBe("en");
});
test("fits the physical page to the available preview width", () => {
expect(getCvPreviewFitZoom(500, 800)).toBeCloseTo(0.595);
expect(getCvPreviewFitZoom(1200, 800)).toBe(1);
expect(getCvPreviewFitZoom(120, 800)).toBe(0.32);
});
});
describe("CV template selection", () => {
test("restores the selected template structure without discarding user content or design choices", () => {
const settings = {
themeId: "minimal",
layout: "single" as const,
headerStyle: "plain" as const,
headingStyle: "plain" as const,
sidebarWidthMm: 70,
sidebarSections: ["skills"],
accentColor: "#123456",
showPhoto: false,
showPageNumbers: false,
showIcons: true,
sections: [{ key: "experience", title: "Career" }],
overrides: {},
customSections: [],
};
expect(applyCvTheme(settings, "technical")).toMatchObject({
themeId: "technical",
layout: null,
headerStyle: null,
headingStyle: null,
sidebarWidthMm: null,
sidebarSections: null,
accentColor: "#123456",
sections: [{ key: "experience", title: "Career" }],
});
});
});