From 5e7dea94b1b6a45d14b4063eeda3e61297b67328 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 18 Nov 2024 08:32:44 +0100 Subject: [PATCH] fix: refs #7917 tests --- .../methods/agency-term/specs/filter.spec.js | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 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 10ec70d45..b1f3eb1f4 100644 --- a/modules/route/back/methods/agency-term/specs/filter.spec.js +++ b/modules/route/back/methods/agency-term/specs/filter.spec.js @@ -3,8 +3,16 @@ 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}}}, + } + }; + }); it('should return all results matching the filter', async() => { const tx = await models.AgencyTerm.beginTransaction({}); @@ -12,7 +20,6 @@ describe('AgencyTerm filter()', () => { try { const options = {transaction: tx}; const filter = {}; - const ctx = {req: {accessToken: {userId: authUserId}}}; const agencyTerms = await models.AgencyTerm.filter(ctx, filter, options); const firstAgencyTerm = agencyTerms[0]; @@ -28,9 +35,8 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "search" searching by integer', async() => { - let ctx = { + ctx = { args: { - ctx: {req: {accessToken: {userId: authUserId}}}, search: 1, } }; @@ -42,9 +48,8 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "search" searching by string', async() => { - let ctx = { + ctx = { args: { - ctx: {req: {accessToken: {userId: authUserId}}}, search: 'Plants SL', } }; @@ -65,14 +70,6 @@ describe('AgencyTerm filter()', () => { const to = Date.vnNew(); to.setHours(23, 59, 59, 999); - const ctx = { - args: { - ctx: {req: {accessToken: {userId: authUserId}}}, - from: from, - to: to - } - }; - const results = await models.AgencyTerm.filter(ctx, options); expect(results.length).toBe(5); @@ -85,9 +82,8 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "agencyModeFk"', async() => { - let ctx = { + ctx = { args: { - ctx: {req: {accessToken: {userId: authUserId}}}, agencyModeFk: 1, } }; @@ -99,9 +95,8 @@ describe('AgencyTerm filter()', () => { }); it('should return results matching "agencyFk"', async() => { - let ctx = { + ctx = { args: { - ctx: {req: {accessToken: {userId: authUserId}}}, agencyFk: 2, } };