refactor(client_updateAddress): refactor ctx variable
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2022-04-06 14:55:59 +02:00
parent afc03fc60e
commit bcbe264f0a
1 changed files with 23 additions and 47 deletions

View File

@ -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);