test: tighten document extractor runtime assertions · openclaw/openclaw@d52ecd3
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,7 +42,7 @@ describe("extractDocumentContent", () => {
|
42 | 42 | }, |
43 | 43 | }, |
44 | 44 | }), |
45 | | -).resolves.toMatchObject({ text: "pdf text", extractor: "pdf" }); |
| 45 | +).resolves.toStrictEqual({ text: "pdf text", images: [], extractor: "pdf" }); |
46 | 46 | |
47 | 47 | expect(extract).toHaveBeenCalledWith({ |
48 | 48 | buffer: Buffer.from("pdf"), |
@@ -65,17 +65,23 @@ describe("extractDocumentContent", () => {
|
65 | 65 | }, |
66 | 66 | ]); |
67 | 67 | |
68 | | -await expect( |
69 | | -extractDocumentContent({ |
| 68 | +let extractionError: unknown; |
| 69 | +try { |
| 70 | +await extractDocumentContent({ |
70 | 71 | buffer: Buffer.from("pdf"), |
71 | 72 | mimeType: "application/pdf", |
72 | 73 | maxPages: 1, |
73 | 74 | maxPixels: 100, |
74 | 75 | minTextChars: 10, |
75 | | -}), |
76 | | -).rejects.toMatchObject({ |
77 | | -message: "Document extraction failed for application/pdf", |
78 | | - cause, |
79 | | -}); |
| 76 | +}); |
| 77 | +} catch (error) { |
| 78 | +extractionError = error; |
| 79 | +} |
| 80 | +expect(extractionError).toBeInstanceOf(Error); |
| 81 | +if (!(extractionError instanceof Error)) { |
| 82 | +throw new Error("expected extraction error"); |
| 83 | +} |
| 84 | +expect(extractionError.message).toBe("Document extraction failed for application/pdf"); |
| 85 | +expect(extractionError.cause).toBe(cause); |
80 | 86 | }); |
81 | 87 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。