salix/services/loopback/common/methods/client/specs/addressesPropagateRe.spec.js

45 lines
1.5 KiB
JavaScript
Raw Normal View History

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();
});
};
2018-01-24 12:45:32 +00:00
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));
});
});