37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
const app = require(`${servicesDir}/client/server/server`);
|
|
|
|
describe('Client addressesPropagateRe', () => {
|
|
beforeEach(async() => {
|
|
await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
|
|
await app.models.Client.update({id: 101}, {hasToInvoiceByAddress: true});
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
|
|
await app.models.Client.update({id: 101}, {hasToInvoiceByAddress: true});
|
|
});
|
|
|
|
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {
|
|
let id = 101;
|
|
let data = {
|
|
isEqualizated: true
|
|
};
|
|
|
|
let resultAddress = await app.models.Address.find({where: {clientFk: id}});
|
|
let resultClient = await app.models.Client.find({where: {id: id}});
|
|
|
|
expect(resultAddress[0].isEqualizated).toBeFalsy();
|
|
expect(resultAddress[1].isEqualizated).toBeFalsy();
|
|
expect(resultClient[0].hasToInvoiceByAddress).toBeTruthy();
|
|
|
|
await app.models.Client.addressesPropagateRe(id, data);
|
|
|
|
resultAddress = await app.models.Address.find({where: {clientFk: id}});
|
|
resultClient = await app.models.Client.find({where: {id: id}});
|
|
|
|
expect(resultAddress[0].isEqualizated).toBeTruthy();
|
|
expect(resultAddress[1].isEqualizated).toBeTruthy();
|
|
expect(resultClient[0].hasToInvoiceByAddress).toBeFalsy();
|
|
});
|
|
});
|