mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 21:30:44 +00:00
test: tighten document extractor runtime assertions
This commit is contained in:
@@ -42,7 +42,7 @@ describe("extractDocumentContent", () => {
|
||||
},
|
||||
},
|
||||
}),
|
||||
).resolves.toMatchObject({ text: "pdf text", extractor: "pdf" });
|
||||
).resolves.toStrictEqual({ text: "pdf text", images: [], extractor: "pdf" });
|
||||
|
||||
expect(extract).toHaveBeenCalledWith({
|
||||
buffer: Buffer.from("pdf"),
|
||||
@@ -65,17 +65,23 @@ describe("extractDocumentContent", () => {
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(
|
||||
extractDocumentContent({
|
||||
let extractionError: unknown;
|
||||
try {
|
||||
await extractDocumentContent({
|
||||
buffer: Buffer.from("pdf"),
|
||||
mimeType: "application/pdf",
|
||||
maxPages: 1,
|
||||
maxPixels: 100,
|
||||
minTextChars: 10,
|
||||
}),
|
||||
).rejects.toMatchObject({
|
||||
message: "Document extraction failed for application/pdf",
|
||||
cause,
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
extractionError = error;
|
||||
}
|
||||
expect(extractionError).toBeInstanceOf(Error);
|
||||
if (!(extractionError instanceof Error)) {
|
||||
throw new Error("expected extraction error");
|
||||
}
|
||||
expect(extractionError.message).toBe("Document extraction failed for application/pdf");
|
||||
expect(extractionError.cause).toBe(cause);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user