2019-11-14 13:19:39 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
2019-11-21 11:00:56 +00:00
|
|
|
describe('sale recalculatePrice()', () => {
|
2019-11-14 13:19:39 +00:00
|
|
|
const saleId = 7;
|
|
|
|
|
|
|
|
it('should update the sale price', async() => {
|
|
|
|
const ctx = {req: {accessToken: {userId: 9}}};
|
2019-11-21 11:00:56 +00:00
|
|
|
const response = await app.models.Sale.recalculatePrice(ctx, saleId);
|
2019-11-14 13:19:39 +00:00
|
|
|
|
|
|
|
expect(response.affectedRows).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should throw an error if the ticket is not editable', async() => {
|
|
|
|
const ctx = {req: {accessToken: {userId: 9}}};
|
|
|
|
const immutableSaleId = 1;
|
2019-11-21 11:00:56 +00:00
|
|
|
await app.models.Sale.recalculatePrice(ctx, immutableSaleId)
|
2019-11-14 13:19:39 +00:00
|
|
|
.catch(response => {
|
|
|
|
expect(response).toEqual(new Error(`The sales of this ticket can't be modified`));
|
|
|
|
error = response;
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(error).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|