From 0c4985604b170362b126f3083c15c8ed376ff66d Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 18 Nov 2024 10:53:52 +0100 Subject: [PATCH] fix: refs #7917 test back --- .../methods/agency-term/specs/filter.spec.js | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/modules/route/back/methods/agency-term/specs/filter.spec.js b/modules/route/back/methods/agency-term/specs/filter.spec.js index b1f3eb1f4..c47b14c95 100644 --- a/modules/route/back/methods/agency-term/specs/filter.spec.js +++ b/modules/route/back/methods/agency-term/specs/filter.spec.js @@ -2,17 +2,9 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; describe('AgencyTerm filter()', () => { - const authUserId = 9; - let ctx; const today = Date.vnNew(); today.setHours(2, 0, 0, 0); - beforeAll(async() => { - ctx = { - args: { - ctx: {req: {accessToken: {userId: authUserId}}}, - } - }; - }); + let ctx = beforeAll.getCtx(); it('should return all results matching the filter', async() => { const tx = await models.AgencyTerm.beginTransaction({}); @@ -35,26 +27,33 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "search" searching by integer', async() => { - ctx = { - args: { - search: 1, - } + // ctx = { + // args: { + // search: 1, + // } + // }; + const filter = { + order: 'isActive ASC, name', + search: 1 }; - let result = await app.models.AgencyTerm.filter(ctx); + let result = await app.models.AgencyTerm.filter(ctx, filter); expect(result.length).toEqual(1); expect(result[0].routeFk).toEqual(1); }); it('should return results matching "search" searching by string', async() => { - ctx = { - args: { - search: 'Plants SL', - } + // ctx = { + // args: { + // search: 'Plants SL', + // } + // }; + const filter = { + search: 'Plants SL' }; - let result = await app.models.AgencyTerm.filter(ctx); + let result = await app.models.AgencyTerm.filter(ctx, filter); expect(result.length).toEqual(2); }); @@ -82,26 +81,31 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "agencyModeFk"', async() => { - ctx = { - args: { - agencyModeFk: 1, - } + // ctx = { + // args: { + // agencyModeFk: 1, + // } + // }; + const filter = { + agencyModeFk: 1, }; - - let result = await app.models.AgencyTerm.filter(ctx); + let result = await app.models.AgencyTerm.filter(ctx, filter); expect(result.length).toEqual(1); expect(result[0].routeFk).toEqual(1); }); it('should return results matching "agencyFk"', async() => { - ctx = { - args: { - agencyFk: 2, - } - }; + // ctx = { + // args: { + // agencyFk: 2, + // } + // }; - let result = await app.models.AgencyTerm.filter(ctx); + const filter = { + agencyFk: 2 + }; + let result = await app.models.AgencyTerm.filter(ctx, filter); expect(result.length).toEqual(1); expect(result[0].routeFk).toEqual(2);