salix/modules/ticket/back/methods/sale/specs/recalculatePrice.spec.js

25 lines
832 B
JavaScript
Raw Normal View History

const app = require('vn-loopback/server/server');
2019-11-21 11:00:56 +00:00
describe('sale recalculatePrice()', () => {
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);
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)
.catch(response => {
expect(response).toEqual(new Error(`The sales of this ticket can't be modified`));
error = response;
});
expect(error).toBeDefined();
});
});