38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
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() => {
|
|
let tomorrow = new Date();
|
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
let data = {
|
|
landed: tomorrow,
|
|
addressFk: 126,
|
|
agencyModeFk: 7,
|
|
warehouseFk: 1
|
|
};
|
|
let result = await app.models.Sale.priceDifference(16, data);
|
|
|
|
expect(result.totalUnitPrice).toEqual(215.77);
|
|
expect(result.totalNewPrice).toEqual(215.77);
|
|
expect(result.totalDifference).toEqual(0);
|
|
});
|
|
|
|
it('should return an error if the ticket is not editable', 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`));
|
|
});
|
|
});
|