From 4104a918fd385321ffdbf26de5e976cf506cba76 Mon Sep 17 00:00:00 2001 From: Gerald Baulig Date: Thu, 31 Oct 2024 14:25:50 +0100 Subject: [PATCH] fix(test): mock fulfillment.evaluate --- src/service.ts | 6 +++--- test/mocks.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/service.ts b/src/service.ts index b1194a5..05909de 100644 --- a/src/service.ts +++ b/src/service.ts @@ -360,7 +360,7 @@ export class OrderingService SOLUTION_NOT_FOUND: { id: '', code: 404, - message: 'Solution for {entity} {id} not found!', + message: 'Solution for {entity} {id} not found!', } }; @@ -1912,7 +1912,7 @@ export class OrderingService r => { r.items?.forEach( fulfillment => { - const id = fulfillment.payload?.references?.[0]?.instance_id ?? fulfillment.status?.id + const id = fulfillment.payload?.references?.[0]?.instance_id ?? fulfillment.status?.id; const order = response_map[id]; if (order && fulfillment.status?.code !== 200) { order.status = fulfillment.status; @@ -2464,7 +2464,7 @@ export class OrderingService return item; } ); - + const created = valids?.length ? await this.fulfillment_service.create( { items: valids.map(item => item.payload), diff --git a/test/mocks.ts b/test/mocks.ts index 3d49106..c37b40f 100644 --- a/test/mocks.ts +++ b/test/mocks.ts @@ -1090,6 +1090,21 @@ export const rules = { totalCount: 1, operationStatus }), + evaluate: ( + call: any, + callback: (error: any, response: FulfillmentListResponse) => void, + ) => callback(null, { + items: call.request.items.map( + (item: FulfillmentResponse) => ({ + payload: item, + status: { + code: 200, + } + }) + ), + totalCount: 1, + operationStatus + }), }, invoice: { create: (