salix/modules/client/back/methods/credit-classification/createWithInsurance.spec.js

27 lines
919 B
JavaScript
Raw Normal View History

2021-07-08 13:53:30 +00:00
const models = require('vn-loopback/server/server').models;
describe('Client createWithInsurance', () => {
2021-07-08 13:53:30 +00:00
it('should create a new client credit classification with insurance', async() => {
const tx = await models.Client.beginTransaction({});
2021-07-08 13:53:30 +00:00
try {
const options = {transaction: tx};
const data = {clientFk: 1101, started: Date.now(), credit: 999, grade: 255};
2021-07-08 13:53:30 +00:00
const result = await models.CreditClassification.createWithInsurance(data, options);
2021-07-08 13:53:30 +00:00
expect(result.client).toEqual(1101);
2021-07-08 13:53:30 +00:00
const classifications = await models.CreditClassification.find();
const insurances = await models.CreditInsurance.find();
2021-07-08 13:53:30 +00:00
expect(classifications.length).toEqual(6);
expect(insurances.length).toEqual(4);
2021-07-08 13:53:30 +00:00
await tx.rollback();
} catch (e) {
await tx.rollback();
}
});
});