refactor: extract buildPdfOptions to DRY up renderPdf/renderUrlPdf (TDD)
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
- Extract shared PDF options construction into buildPdfOptions() - Both renderPdf and renderUrlPdf now use the shared builder - 5 TDD tests added (pdf-options-builder.test.ts) - 633 tests passing, 0 tsc errors
This commit is contained in:
parent
b1a09f7b3f
commit
4e00feb860
3 changed files with 98 additions and 31 deletions
|
|
@ -53,7 +53,10 @@ vi.mock("../services/keys.js", () => {
|
|||
});
|
||||
|
||||
// Mock browser service
|
||||
vi.mock("../services/browser.js", () => ({
|
||||
vi.mock("../services/browser.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<Record<string, unknown>>();
|
||||
return {
|
||||
buildPdfOptions: actual.buildPdfOptions,
|
||||
initBrowser: vi.fn().mockResolvedValue(undefined),
|
||||
closeBrowser: vi.fn().mockResolvedValue(undefined),
|
||||
renderPdf: vi.fn().mockResolvedValue({ pdf: Buffer.from("%PDF-1.4 mock pdf content here"), durationMs: 10 }),
|
||||
|
|
@ -68,7 +71,8 @@ vi.mock("../services/browser.js", () => ({
|
|||
uptimeMs: 10000,
|
||||
browsers: [],
|
||||
}),
|
||||
}));
|
||||
};
|
||||
});
|
||||
|
||||
// Mock verification service
|
||||
vi.mock("../services/verification.js", () => ({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue