added throw to catch in many tests

This commit is contained in:
Carlos Jimenez Ruiz 2021-08-12 10:55:04 +02:00
parent da7bda2d0e
commit 2c3f46f394
24 changed files with 79 additions and 12 deletions

View File

@ -32,6 +32,7 @@ describe('client canBeInvoiced()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -51,6 +52,7 @@ describe('client canBeInvoiced()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -67,6 +69,7 @@ describe('client canBeInvoiced()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -15,6 +15,7 @@ describe('Client canCreateTicket', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -32,6 +33,7 @@ describe('Client canCreateTicket', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -21,6 +21,7 @@ describe('Client confirmTransaction', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -14,13 +14,14 @@ describe('client consumption() filter', () => {
},
order: 'itemTypeFk, itemName, itemSize'
};
const result = await app.models.Client.consumption(ctx, filter, options);
const result = await models.Client.consumption(ctx, filter, options);
expect(result.length).toEqual(10);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -41,7 +42,7 @@ describe('client consumption() filter', () => {
},
order: 'itemFk'
};
const result = await app.models.Client.consumption(ctx, filter, options);
const result = await models.Client.consumption(ctx, filter, options);
const firstRow = result[0];
const secondRow = result[1];
@ -55,6 +56,7 @@ describe('client consumption() filter', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -75,7 +77,7 @@ describe('client consumption() filter', () => {
},
order: 'itemTypeFk, itemName, itemSize'
};
const result = await app.models.Client.consumption(ctx, filter, options);
const result = await models.Client.consumption(ctx, filter, options);
const expectedItemId = 4;
const firstRow = result[0];
@ -85,6 +87,7 @@ describe('client consumption() filter', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -99,6 +99,7 @@ describe('Address createAddress', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -132,6 +133,7 @@ describe('Address createAddress', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -50,6 +50,7 @@ describe('Client createReceipt', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -147,6 +148,7 @@ describe('Client createReceipt', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -187,6 +189,7 @@ describe('Client createReceipt', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -26,6 +26,7 @@ describe('Client Create', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -48,6 +49,7 @@ describe('Client Create', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});

View File

@ -14,6 +14,7 @@ describe('client getAverageInvoiced()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -17,6 +17,7 @@ describe('Client getCard()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -14,6 +14,7 @@ describe('client getDebt()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -14,6 +14,7 @@ describe('client getMana()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -15,6 +15,7 @@ describe('Client getTransations', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -16,6 +16,7 @@ describe('Client hasCustomerRole', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -33,6 +34,7 @@ describe('Client hasCustomerRole', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -51,6 +53,7 @@ describe('Client hasCustomerRole', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -69,6 +72,7 @@ describe('Client hasCustomerRole', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -15,6 +15,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -32,6 +33,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -49,6 +51,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -66,6 +69,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -83,6 +87,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -100,6 +105,7 @@ describe('Client isValidClient', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -22,6 +22,7 @@ describe('Client last active tickets', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -15,7 +15,7 @@ describe('client sendSms()', () => {
const sms = await models.Client.sendSms(ctx, id, destination, message, options);
const createdLog = await models.ClientLog.findById(sms.logId);
const createdLog = await models.ClientLog.findById(sms.logId, null, options);
const json = JSON.parse(JSON.stringify(createdLog.newInstance));
expect(json.message).toEqual(message);
@ -23,6 +23,7 @@ describe('client sendSms()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -16,6 +16,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -33,6 +34,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -50,6 +52,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -67,6 +70,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -84,6 +88,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -101,6 +106,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -118,6 +124,7 @@ describe('client summary()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -64,6 +64,8 @@ describe('Address updateAddress', () => {
try {
const options = {transaction: tx};
const expectedResult = 'My edited address';
const ctx = {
args: {
provinceFk: provinceId,
@ -72,7 +74,6 @@ describe('Address updateAddress', () => {
customsAgentFk: customAgentOneId
}
};
const expectedResult = 'My edited address';
await models.Client.updateAddress(ctx, clientId, addressId, options);
@ -83,6 +84,7 @@ describe('Address updateAddress', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -91,12 +93,13 @@ describe('Address updateAddress', () => {
try {
const options = {transaction: tx};
const expectedResult = 'My second time edited address';
const ctx = {
args: {
nickname: expectedResult
}
};
const expectedResult = 'My second time edited address';
await models.Client.updateAddress(ctx, clientId, addressId, options);
@ -107,6 +110,7 @@ describe('Address updateAddress', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -71,6 +71,7 @@ describe('Client updateFiscalData', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -20,8 +20,8 @@ module.exports = Self => {
Self.createWithInsurance = async(data, options) => {
const models = Self.app.models;
let tx;
const myOptions = {};
let tx;
if (typeof options == 'object')
Object.assign(myOptions, options);

View File

@ -1,6 +1,23 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('Client createWithInsurance', () => {
const activeCtx = {
accessToken: {userId: 19},
http: {
req: {
headers: {origin: 'http://localhost/'},
__: () => {}
}
}
};
beforeAll(async() => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx,
});
});
it('should create a new client credit classification with insurance', async() => {
const tx = await models.Client.beginTransaction({});
@ -12,8 +29,8 @@ describe('Client createWithInsurance', () => {
expect(result.client).toEqual(1101);
const classifications = await models.CreditClassification.find();
const insurances = await models.CreditInsurance.find();
const classifications = await models.CreditClassification.find(null, options);
const insurances = await models.CreditInsurance.find(null, options);
expect(classifications.length).toEqual(6);
expect(insurances.length).toEqual(4);
@ -21,6 +38,7 @@ describe('Client createWithInsurance', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -7,15 +7,16 @@ describe('Greuge totalGreuge()', () => {
try {
const options = {transaction: tx};
const clientId = 1;
const clientId = 1101;
const result = await models.Client.sumAmount(clientId, options);
const result = await models.Greuge.sumAmount(clientId, options);
expect(result).toBe(6000);
expect(result).toBe(203.71);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -17,6 +17,7 @@ describe('receipt filter()', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});

View File

@ -14,6 +14,7 @@ describe('client hasActiveRecovery', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
@ -30,6 +31,7 @@ describe('client hasActiveRecovery', () => {
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});