From a5b3bdfa8db840dccbd3dbfff3e800a023825bef Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 28 Mar 2022 13:24:11 +0200 Subject: [PATCH] feat: add backTest --- .../travel/specs/extraCommunityFilter.spec.js | 63 ++++++++++++++++--- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 7f42eb5f0..b74160efe 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -46,15 +46,64 @@ describe('Travel extraCommunityFilter()', () => { expect(result.length).toEqual(3); }); - it('should return the routes matching "landed from" and "landed to"', async() => { - const from = new Date(); - const to = new Date(); - from.setHours(0, 0, 0, 0); - to.setHours(23, 59, 59, 999); - to.setDate(to.getDate() + 14); + it('should return the travel matching "warehouse in"', async() => { const ctx = { args: { - landedFrom: from, + warehouseInFk: 1 + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result.length).toEqual(4); + }); + + it('should return the travel matching "continent"', async() => { + const ctx = { + args: { + continent: 'AM' + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result.length).toEqual(3); + }); + + it('should return the travel matching "agencyFk"', async() => { + const ctx = { + args: { + agencyFk: 1 + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result.length).toEqual(8); + }); + + it('should return the travel matching "cargoSupplierFk"', async() => { + const ctx = { + args: { + cargoSupplierFk: 1 + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result.length).toEqual(4); + }); + + it('should return the routes matching "shipped from" and "landed to"', async() => { + const from = new Date(); + from.setDate(from.getDate() - 2); + from.setHours(0, 0, 0, 0); + const to = new Date(); + to.setHours(23, 59, 59, 999); + to.setDate(to.getDate() + 7); + const ctx = { + args: { + shippedFrom: from, landedTo: to } };