25 lines
811 B
JavaScript
25 lines
811 B
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('sale calculate()', () => {
|
|
const saleId = 7;
|
|
|
|
it('should update the sale price', async() => {
|
|
const ctx = {req: {accessToken: {userId: 9}}};
|
|
const response = await app.models.Sale.calculate(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;
|
|
await app.models.Sale.calculate(ctx, immutableSaleId)
|
|
.catch(response => {
|
|
expect(response).toEqual(new Error(`The sales of this ticket can't be modified`));
|
|
error = response;
|
|
});
|
|
|
|
expect(error).toBeDefined();
|
|
});
|
|
});
|