2021-07-08 13:53:30 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2018-04-23 12:50:06 +00:00
|
|
|
|
|
|
|
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({});
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
const data = {clientFk: 1101, started: Date.now(), credit: 999, grade: 255};
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
const result = await models.CreditClassification.createWithInsurance(data, options);
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
expect(result.client).toEqual(1101);
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
const classifications = await models.CreditClassification.find();
|
|
|
|
const insurances = await models.CreditInsurance.find();
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
expect(classifications.length).toEqual(6);
|
|
|
|
expect(insurances.length).toEqual(4);
|
2018-04-23 12:50:06 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
}
|
2018-04-23 12:50:06 +00:00
|
|
|
});
|
|
|
|
});
|