40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
const app = require(`${servicesDir}/client/server/server`);
|
|
const restoreFixtures = require(`${servicesDir}/db/testing_fixtures`);
|
|
|
|
describe('Client addressesPropagateRe', () => {
|
|
let sqlStatements = {deletes: ``, inserts: ``, updates:
|
|
`UPDATE vn.address SET isEqualizated = FALSE WHERE clientFk = 101;
|
|
UPDATE vn.client SET hasToInvoiceByAddress = TRUE WHERE id = 101;`
|
|
};
|
|
beforeEach(() => {
|
|
restoreFixtures(sqlStatements);
|
|
});
|
|
|
|
afterAll(() => {
|
|
restoreFixtures(sqlStatements);
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|