const app = require(`${servicesDir}/order/server/server`); describe('Order updateBasicData', () => { afterAll(async () => { let validparams = {note: null}; let orderId = 21; await app.models.Order.updateBasicData(validparams, orderId); }); it('should return an error if the order is confirmed', async () => { let error; let params = []; let orderConfirmed = 1; await app.models.Order.updateBasicData(params, orderConfirmed) .catch(e => { error = e; }); expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`); }); it('should return an error if the order has rows', async () => { let error; let params = []; let orderWithRows = 16; await app.models.Order.updateBasicData(params, orderWithRows) .catch(e => { error = e; }); expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`); }); it('should return an error if the user is administrative and the isTaxDataChecked value is true BUT the params aint valid', async () => { let error; let invalidparams = {invalid: 'param for update'}; let orderId = 21; await app.models.Order.updateBasicData(invalidparams, orderId) .catch(e => { error = e; }); expect(error.toString()).toContain(`You don't have enough privileges to do that`); }); it('should update the client fiscal data and return the count if changes made', async () => { let validparams = {note: 'test note'}; let orderId = 21; let order = await app.models.Order.findById(orderId); expect(order.note).toEqual(null); let result = await app.models.Order.updateBasicData(validparams, orderId); expect(result.note).toEqual('test note'); }); });