2018-08-13 12:52:05 +00:00
|
|
|
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() => {
|
2018-08-13 12:52:05 +00:00
|
|
|
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);
|
|
|
|
|
2018-10-03 10:53:30 +00:00
|
|
|
expect(result.email).toEqual('myNewEmail@myDomain.es');
|
2018-08-13 12:52:05 +00:00
|
|
|
});
|
|
|
|
});
|