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`); }); it('should update the client discal 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).toEqual({count: 1}); let updatedClient = await app.models.Client.findById(101); expect(updatedClient.email).toEqual('myNewEmail@myDomain.es'); }); });