test: guard document extract mock calls · openclaw/openclaw@225a374
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -36,6 +36,14 @@ import { createPdfDocumentExtractor } from "./document-extractor.js";
|
36 | 36 | |
37 | 37 | const require = createRequire(import.meta.url); |
38 | 38 | |
| 39 | +function requireFirstMockArg(mock: ReturnType<typeof vi.fn>, label: string) { |
| 40 | +const [call] = mock.mock.calls; |
| 41 | +if (!call) { |
| 42 | +throw new Error(`Expected ${label}`); |
| 43 | +} |
| 44 | +return call[0]; |
| 45 | +} |
| 46 | + |
39 | 47 | describe("PDF document extractor", () => { |
40 | 48 | afterAll(() => { |
41 | 49 | vi.doUnmock("pdfjs-dist/legacy/build/pdf.mjs"); |
@@ -92,7 +100,7 @@ describe("PDF document extractor", () => {
|
92 | 100 | }); |
93 | 101 | |
94 | 102 | expect(getDocumentMock).toHaveBeenCalledTimes(1); |
95 | | -const [params] = getDocumentMock.mock.calls[0] ?? []; |
| 103 | +const params = requireFirstMockArg(getDocumentMock, "pdfjs getDocument call"); |
96 | 104 | const { data, standardFontDataUrl, ...stableParams } = params as { |
97 | 105 | data: Uint8Array; |
98 | 106 | disableWorker: boolean; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。