45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
const app = require('../../../../../client/server/server');
|
|
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
|
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
|
|
|
describe('Client addressesPropagateRe', () => {
|
|
let sqlStatements = {deletes: ``, inserts: ``, updates:
|
|
`UPDATE vn.address SET isEqualizated = 0 WHERE clientFk = 101;`
|
|
};
|
|
beforeEach(() => {
|
|
restoreFixtures(sqlStatements);
|
|
});
|
|
|
|
afterAll(() => {
|
|
restoreFixtures(sqlStatements);
|
|
});
|
|
|
|
it('should propagate the isEqualizated on both addresses of Mr Wayne', done => {
|
|
let id = 101;
|
|
let data = {
|
|
isEqualizated: true
|
|
};
|
|
|
|
let callback = (error, result) => {
|
|
if (error) return catchErrors(done)(error);
|
|
|
|
expect(result).toBe(true);
|
|
app.models.Address.find({where: {clientFk: id}})
|
|
.then(result => {
|
|
expect(result[0].isEqualizated).toBeTruthy();
|
|
expect(result[1].isEqualizated).toBeTruthy();
|
|
done();
|
|
});
|
|
};
|
|
app.models.Address.find({where: {clientFk: id}})
|
|
.then(result => {
|
|
expect(result[0].isEqualizated).toBeFalsy();
|
|
expect(result[1].isEqualizated).toBeFalsy();
|
|
})
|
|
.then(() => {
|
|
app.models.Client.addressesPropagateRe(id, data, callback);
|
|
})
|
|
.catch(catchErrors(done));
|
|
});
|
|
});
|