11import { expect } from "chai" ;
22import path from "node:path" ;
3+ import { Polygon } from "@/geometry/index.js" ;
4+ import { crop } from "@/v2/product/index.js" ;
5+
36import { V2_PRODUCT_PATH } from "../../index.js" ;
4- import { CropResponse , CropItem } from "@/v2/product/index.js" ;
57import { loadV2Response } from "./utils.js" ;
6- import { Polygon } from "@/geometry/index.js" ;
78
89describe ( "MindeeV2 - Crop Response" , async ( ) => {
910 it ( "should load a single result" , async ( ) => {
1011 const response = await loadV2Response (
11- CropResponse ,
12+ crop . CropResponse ,
1213 path . join ( V2_PRODUCT_PATH , "crop" , "crop_single.json" )
1314 ) ;
1415 // Validate inference metadata
@@ -21,14 +22,14 @@ describe("MindeeV2 - Crop Response", async () => {
2122 expect ( response . inference . file . mimeType ) . to . equal ( "image/jpeg" ) ;
2223
2324 // Validate crops
24- const crops = response . inference . result . crops ;
25+ const crops : crop . CropItem [ ] = response . inference . result . crops ;
2526 expect ( crops ) . to . be . an ( "array" ) . that . has . lengthOf ( 1 ) ;
2627
27- const crop : CropItem = crops [ 0 ] ;
28- expect ( crop . objectType ) . to . equal ( "invoice" ) ;
29- expect ( crop . location . page ) . to . equal ( 0 ) ;
28+ const firstCrop = crops [ 0 ] ;
29+ expect ( firstCrop . objectType ) . to . equal ( "invoice" ) ;
30+ expect ( firstCrop . location . page ) . to . equal ( 0 ) ;
3031
31- const polygon : Polygon = crop . location . polygon ! ;
32+ const polygon : Polygon = firstCrop . location . polygon ! ;
3233 expect ( polygon . length ) . to . equal ( 4 ) ;
3334 expect ( polygon . length ) . to . equal ( 4 ) ;
3435 expect ( polygon [ 0 ] [ 0 ] ) . to . equal ( 0.15 ) ;
@@ -43,7 +44,7 @@ describe("MindeeV2 - Crop Response", async () => {
4344
4445 it ( "should load multiple results" , async ( ) => {
4546 const response = await loadV2Response (
46- CropResponse ,
47+ crop . CropResponse ,
4748 path . join ( V2_PRODUCT_PATH , "crop" , "crop_multiple.json" )
4849 ) ;
4950 // Validate inference metadata
@@ -55,11 +56,11 @@ describe("MindeeV2 - Crop Response", async () => {
5556 expect ( response . inference . file . pageCount ) . to . equal ( 1 ) ;
5657 expect ( response . inference . file . mimeType ) . to . equal ( "image/jpeg" ) ;
5758
58- const crops : CropItem [ ] = response . inference . result . crops ;
59+ const crops : crop . CropItem [ ] = response . inference . result . crops ;
5960 expect ( crops ) . to . be . an ( "array" ) . that . has . lengthOf ( 2 ) ;
6061
6162 // Validate first crop item
62- const firstCrop : CropItem = crops [ 0 ] ;
63+ const firstCrop : crop . CropItem = crops [ 0 ] ;
6364 expect ( firstCrop . objectType ) . to . equal ( "invoice" ) ;
6465 expect ( firstCrop . location . page ) . to . equal ( 0 ) ;
6566 const firstPolygon : Polygon = firstCrop . location . polygon ! ;
@@ -74,7 +75,7 @@ describe("MindeeV2 - Crop Response", async () => {
7475 expect ( firstPolygon [ 3 ] [ 1 ] ) . to . equal ( 0.979 ) ;
7576
7677 // Validate second crop item
77- const secondCrop : CropItem = crops [ 1 ] ;
78+ const secondCrop : crop . CropItem = crops [ 1 ] ;
7879 expect ( secondCrop . objectType ) . to . equal ( "invoice" ) ;
7980 expect ( secondCrop . location . page ) . to . equal ( 0 ) ;
8081 const secondPolygon : Polygon = secondCrop . location . polygon ! ;
0 commit comments