salix/modules/client/back/methods/client/specs/addressesPropagateRe.spec.js

34 lines
1.0 KiB
JavaScript

const models = require('vn-loopback/server/server').models;
describe('Client addressesPropagateRe', () => {
beforeAll.mockLoopBackContext();
it('should propagate the isEqualizated on both addresses of Mr Wayne' +
' and set hasToInvoiceByAddress to false', async() => {
const tx = await models.Client.beginTransaction({});
try {
const options = {transaction: tx};
let id = 1101;
let data = {
isEqualizated: true
};
await models.Client.addressesPropagateRe(id, data, options);
const addresses = await models.Address.find({where: {clientFk: id}}, options);
const client = await models.Client.findById(id, null, options);
expect(addresses[0].isEqualizated).toBeTruthy();
expect(addresses[1].isEqualizated).toBeTruthy();
expect(client.hasToInvoiceByAddress).toBeFalsy();
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});