#1181 No modificar ticket.basicData en reparto
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-04-01 15:04:09 +02:00
parent 62acb534e1
commit 056c07b17c
1 changed files with 23 additions and 4 deletions

View File

@ -1,4 +1,5 @@
const app = require('vn-loopback/server/server');
let UserError = require('vn-loopback/util/user-error');
describe('sale priceDifference()', () => {
it('should return ticket price differences', async() => {
@ -8,10 +9,28 @@ describe('sale priceDifference()', () => {
agencyModeFk: 1,
warehouseFk: 1
};
let result = await app.models.Sale.priceDifference(1, data);
let result = await app.models.Sale.priceDifference(11, data);
expect(result.totalUnitPrice).toEqual(22.33);
expect(result.totalNewPrice).toEqual(22.27);
expect(result.totalDifference).toEqual(0.87);
expect(result.totalUnitPrice).toEqual(4.5);
expect(result.totalNewPrice).toEqual(4.24);
expect(result.totalDifference).toEqual(3.75);
});
it('should return an error if the ticket state is not valid for modifications', async() => {
let error;
let data = {
landed: new Date(),
addressFk: 121,
agencyModeFk: 1,
warehouseFk: 1
};
await app.models.Sale.priceDifference(1, data)
.catch(e => {
error = e;
});
expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`));
});
});