From bcbe264f0a6ae0998a20072887952ce50c4d1311 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 6 Apr 2022 14:55:59 +0200 Subject: [PATCH] refactor(client_updateAddress): refactor ctx variable --- .../client/specs/updateAddress.spec.js | 70 ++++++------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 101038f9d..7aea6fcd7 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -6,6 +6,11 @@ describe('Address updateAddress', () => { const provinceId = 5; const incotermsId = 'FAS'; const customAgentOneId = 1; + const ctx = { + req: { + accessToken: {userId: 1} + } + }; it('should throw the non uee member error if no incoterms is defined', async() => { const tx = await models.Client.beginTransaction({}); @@ -14,14 +19,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - customsAgentFk: customAgentOneId - } + ctx.args = { + provinceFk: provinceId, + customsAgentFk: customAgentOneId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -43,14 +43,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - incotermsFk: incotermsId - } + ctx.args = { + provinceFk: provinceId, + incotermsFk: incotermsId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -72,16 +67,11 @@ describe('Address updateAddress', () => { const options = {transaction: tx}; const expectedResult = 'My edited address'; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - provinceFk: provinceId, - nickname: expectedResult, - incotermsFk: incotermsId, - customsAgentFk: customAgentOneId - } + ctx.args = { + provinceFk: provinceId, + nickname: expectedResult, + incotermsFk: incotermsId, + customsAgentFk: customAgentOneId }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -102,13 +92,8 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - isLogifloraAllowed: true - } + ctx.args = { + isLogifloraAllowed: true }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -126,13 +111,9 @@ describe('Address updateAddress', () => { try { const options = {transaction: tx}; - const ctx = { - req: { - accessToken: {userId: 21} - }, - args: { - isLogifloraAllowed: true - } + ctx.req.accessToken.userId = 21; + ctx.args = { + isLogifloraAllowed: true }; await models.Client.updateAddress(ctx, clientId, addressId, options); @@ -154,13 +135,8 @@ describe('Address updateAddress', () => { const options = {transaction: tx}; const expectedResult = 'My second time edited address'; - const ctx = { - req: { - accessToken: {userId: 1} - }, - args: { - nickname: expectedResult - } + ctx.args = { + nickname: expectedResult }; await models.Client.updateAddress(ctx, clientId, addressId, options);