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

38 lines
1.1 KiB
JavaScript
Raw Normal View History

const app = require(`${servicesDir}/client/server/server`);
describe('Client updateBasicData', () => {
afterAll(async() => {
let id = 101;
let validparams = {email: 'BruceWayne@verdnatura.es'};
await app.models.Client.updateBasicData(validparams, id);
});
it('should return an error if the params aint valid', async() => {
let error;
let id = 101;
let invalidparams = {invalid: 'param for update'};
await app.models.Client.updateBasicData(invalidparams, id)
.catch(e => {
error = e;
});
expect(error.toString()).toContain(`You don't have enough privileges to do that`);
});
2018-09-27 08:03:11 +00:00
it('should update the client fiscal data and return the count if changes made', async() => {
let id = 101;
let client = await app.models.Client.findById(id);
expect(client.email).toEqual('BruceWayne@verdnatura.es');
let validparams = {email: 'myNewEmail@myDomain.es'};
let result = await app.models.Client.updateBasicData(validparams, id);
expect(result.email).toEqual('myNewEmail@myDomain.es');
});
});