mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-25 07:42:20 +10:00
refactor(import): add v4section/v4url aliases, inline clamp wrappers, replace classes with fns
Finding 5: Introduce V4Url + V4Section<T> type aliases in reactive-resume-v4-json.tsx; collapse
310-line V4ResumeData type (13x 5-field section header, 11x {label,href}) into typed aliases.
Inferred shape is structurally identical.
Finding 6: Remove 9 single-caller clamp/pxToPt wrappers; replace compile-time constants
(rotation=0, sidebarWidth=35, shadowWidth=0, gapX=4, gapY=6) with literals; inline dynamic
calls (clamp(x, 32, 512) etc.) at the two body/heading typography call sites.
Finding 7: Convert three stateless single-method importer classes to plain functions.
Extract shared rethrowAsImportError() to error.ts, replacing triplicated ZodError catch blocks.
Update web import dialog + all in-package test files to use function API.
Claude-Session: https://claude.ai/code/session_012Bnvt1MghwHj4qQRxuQUGa
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { ReactiveResumeV4JSONImporter } from "./reactive-resume-v4-json";
|
||||
import { parseReactiveResumeV4JSON } from "./reactive-resume-v4-json";
|
||||
|
||||
const baseV4 = () => ({
|
||||
basics: {
|
||||
@@ -205,11 +205,9 @@ const baseV4 = () => ({
|
||||
},
|
||||
});
|
||||
|
||||
const importer = new ReactiveResumeV4JSONImporter();
|
||||
|
||||
describe("ReactiveResumeV4JSONImporter — broad section mapping", () => {
|
||||
describe("parseReactiveResumeV4JSON — broad section mapping", () => {
|
||||
const v4 = baseV4();
|
||||
const result = importer.parse(JSON.stringify(v4));
|
||||
const result = parseReactiveResumeV4JSON(JSON.stringify(v4));
|
||||
|
||||
it("maps basics fields (name, headline, contact, website, customFields)", () => {
|
||||
expect(result.basics.name).toBe("Jane Doe");
|
||||
@@ -303,6 +301,6 @@ describe("ReactiveResumeV4JSONImporter — broad section mapping", () => {
|
||||
});
|
||||
|
||||
it("invalid JSON throws", () => {
|
||||
expect(() => importer.parse("not json")).toThrow();
|
||||
expect(() => parseReactiveResumeV4JSON("not json")).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user