salix/back/methods/collection/spec/setSaleQuantity.spec.js

28 lines
867 B
JavaScript
Raw Normal View History

const models = require('vn-loopback/server/server').models;
describe('setSaleQuantity()', () => {
it('should change quantity sale', async() => {
2022-11-25 10:50:24 +00:00
const tx = await models.Ticket.beginTransaction({});
2022-11-25 10:50:24 +00:00
try {
const options = {transaction: tx};
2022-11-25 10:50:24 +00:00
const saleId = 30;
const newQuantity = 10;
2022-11-25 10:50:24 +00:00
const originalSale = await models.Sale.findById(saleId, null, options);
await models.Collection.setSaleQuantity(saleId, newQuantity, options);
const updateSale = await models.Sale.findById(saleId, null, options);
expect(updateSale.originalQuantity).toEqual(originalSale.quantity);
expect(updateSale.quantity).toEqual(newQuantity);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});