2018-08-21 10:56:32 +00:00
|
|
|
const app = require(`${servicesDir}/ticket/server/server`);
|
|
|
|
|
|
|
|
describe('sale removes()', () => {
|
2018-08-22 06:24:54 +00:00
|
|
|
let sale;
|
2018-08-21 10:56:32 +00:00
|
|
|
|
2018-08-22 06:24:54 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
sale = await app.models.Sale.findOne({where: {id: 1}});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await app.models.Sale.create(sale);
|
2018-08-21 10:56:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
|
|
|
let error;
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
sales: [{id: 1, instance: 0}, {id: 2, instance: 1}],
|
|
|
|
actualTicketFk: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
await app.models.Sale.removes(params);
|
|
|
|
} catch (e) {
|
|
|
|
error = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(error).toEqual(new Error(`The sales of this ticket can't be modified`));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete the sales', async() => {
|
|
|
|
let params = {
|
2018-08-22 06:24:54 +00:00
|
|
|
sales: [{id: 1, instance: 0}],
|
2018-08-21 10:56:32 +00:00
|
|
|
actualTicketFk: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
let res = await app.models.Sale.removes(params);
|
|
|
|
|
2018-08-22 06:24:54 +00:00
|
|
|
expect(res).toEqual([{count: 1}]);
|
2018-08-21 10:56:32 +00:00
|
|
|
});
|
|
|
|
});
|