client Card backend unit tests
This commit is contained in:
parent
4b8eb3de85
commit
48aef1f9b0
|
@ -19,7 +19,7 @@ module.exports = function(Client) {
|
|||
}
|
||||
});
|
||||
|
||||
Client.card = function(id, cb) {
|
||||
Client.card = function(id, callback) {
|
||||
let filter = {
|
||||
where: {
|
||||
id: id
|
||||
|
@ -27,10 +27,10 @@ module.exports = function(Client) {
|
|||
include: require('./card.json')
|
||||
};
|
||||
|
||||
Client.find(filter, function(err, instances) {
|
||||
if (!err) {
|
||||
cb(null, formatCard(instances[0]));
|
||||
}
|
||||
Client.find(filter, function(error, instances) {
|
||||
if (error) throw error;
|
||||
|
||||
callback(null, formatCard(instances[0]));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import app from '../../../../server/server';
|
||||
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
||||
import restoreFixtures from '../../../../../../services/db/testing_fixtures';
|
||||
import { fileExistsSync } from '../../../../../loopback/node_modules/loopback-boot/lib/utils';
|
||||
|
||||
describe('Client addressesPropagateRe', () => {
|
||||
let fixturesToApply = {tables: ['`account`.`user`', '`vn2008`.`Clientes`', '`vn2008`.`Consignatarios`'], inserts: [
|
||||
|
@ -60,12 +59,6 @@ describe('Client addressesPropagateRe', () => {
|
|||
isEqualizated: true
|
||||
};
|
||||
|
||||
app.models.Address.find({where: {clientFk: id}})
|
||||
.then(result => {
|
||||
expect(result[0].isEqualizated).toBeFalsy();
|
||||
expect(result[1].isEqualizated).toBeFalsy();
|
||||
});
|
||||
|
||||
let callback = (error, result) => {
|
||||
if (error) return catchErrors(done)(error);
|
||||
|
||||
|
@ -77,6 +70,15 @@ describe('Client addressesPropagateRe', () => {
|
|||
done();
|
||||
});
|
||||
};
|
||||
app.models.Client.addressesPropagateRe(id, data, callback);
|
||||
|
||||
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));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import app from '../../../../server/server';
|
||||
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
|
||||
|
||||
describe('Client card', () => {
|
||||
it('should call the card() method to receive a formatd card', done => {
|
||||
let id = 1;
|
||||
|
||||
let callback = (error, result) => {
|
||||
if (error) return catchErrors(done)(error);
|
||||
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
id: 1,
|
||||
name: 'Bruce Wayne'
|
||||
}));
|
||||
done();
|
||||
};
|
||||
|
||||
app.models.Client.card(id, callback);
|
||||
});
|
||||
});
|
|
@ -17,7 +17,7 @@ describe('Client Create', () => {
|
|||
(9, 'BruceBanner', 'ac754a330530832ba1bf7687f577da91', 18, 1, 'BruceBanner@verdnatura.es'),
|
||||
(10, 'JessicaJones', 'ac754a330530832ba1bf7687f577da91', 9, 1, 'JessicaJones@verdnatura.es'),
|
||||
(11, 'Cyborg', 'ac754a330530832ba1bf7687f577da91', 1, 1, 'cyborg@verdnatura.es');
|
||||
|
||||
|
||||
INSERT INTO salix.Address(id, consignee, street, city, postcode, provinceFk, phone, mobile, isEnabled, isDefaultAddress, clientFk, defaultAgencyFk, longitude, latitude, isEqualizated)
|
||||
VALUES
|
||||
(1, 'Bruce Wayne', 'The Bat cave', 'Silla', 46460, 1, NULL, NULL, 1, 1, 1, 2, NULL, NULL, 0),
|
||||
|
|
Loading…
Reference in New Issue