|
1 | 1 | import { expect } from "chai"; |
2 | 2 | import path from "node:path"; |
3 | | -import { LocalResponse, InferenceResponse } from "../../../src"; |
| 3 | +import { LocalResponse, InferenceResponse, RawText } from "../../../src"; |
4 | 4 | import { FieldConfidence, ListField, ObjectField, SimpleField } from "../../../src/parsing/v2/field"; |
5 | 5 | import { promises as fs } from "node:fs"; |
6 | 6 | import { Polygon } from "../../../src/geometry"; |
@@ -236,22 +236,19 @@ describe("inference", async () => { |
236 | 236 | }); |
237 | 237 | }); |
238 | 238 |
|
239 | | - describe("options", async () => { |
240 | | - it("raw texts should be exposed", async () => { |
| 239 | + describe("raw text", async () => { |
| 240 | + it("raw text should be exposed", async () => { |
241 | 241 | const response = await loadV2Inference(rawTextPath); |
242 | | - const opts = response.inference.result.options; |
| 242 | + const rawText = response.inference.result.rawText; |
243 | 243 |
|
244 | | - expect(opts).to.not.be.undefined; |
245 | | - const rawTexts = |
246 | | - (opts as any).rawTexts ?? (opts as any).getRawTexts?.() ?? []; |
| 244 | + expect(rawText).to.be.instanceOf(RawText); |
247 | 245 |
|
248 | | - expect(rawTexts).to.be.an("array").and.have.lengthOf(2); |
| 246 | + const pages = rawText?.pages; |
| 247 | + if (pages === undefined) throw new Error("pages is undefined"); |
249 | 248 |
|
250 | | - const first = rawTexts[0]; |
251 | | - expect(first.page).to.eq(0); |
252 | | - expect(first.content).to.eq( |
253 | | - "This is the raw text of the first page..." |
254 | | - ); |
| 249 | + expect(pages).to.be.an("array").and.have.lengthOf(2); |
| 250 | + const first = pages[0]; |
| 251 | + expect(first.content).to.eq("This is the raw text of the first page..."); |
255 | 252 | }); |
256 | 253 | }); |
257 | 254 |
|
|
0 commit comments