26 行
1023 B
JavaScript
26 行
1023 B
JavaScript
const { mapInvoiceDocumentMeta } = require("../../../src/services/invoiceDocumentMeta");
|
|
|
|
describe("invoice document metadata", () => {
|
|
it("exposes only supported document categories and a bounded subtype", () => {
|
|
expect(mapInvoiceDocumentMeta({
|
|
ocr_result: {
|
|
result_json: {
|
|
documentCategory: " electronic_train_ticket ",
|
|
documentSubtype: `ElectronicTrainTicketFull${"x".repeat(80)}`,
|
|
raw: { sensitive: true },
|
|
},
|
|
},
|
|
})).toEqual({
|
|
documentCategory: "electronic_train_ticket",
|
|
documentSubtype: `ElectronicTrainTicketFull${"x".repeat(39)}`,
|
|
});
|
|
});
|
|
|
|
it("fails closed for unknown, blank, or malformed OCR metadata", () => {
|
|
expect(mapInvoiceDocumentMeta({
|
|
ocr_result: { result_json: { documentCategory: "unknown_invoice", documentSubtype: " " } },
|
|
})).toEqual({ documentCategory: null, documentSubtype: null });
|
|
expect(mapInvoiceDocumentMeta(null)).toEqual({ documentCategory: null, documentSubtype: null });
|
|
});
|
|
});
|