const models = require('vn-loopback/server/server').models; describe('setSaleQuantity()', () => { it('should change quantity sale', async() => { const tx = await models.Ticket.beginTransaction({}); try { const options = {transaction: tx}; const saleId = 30; const newQuantity = 10; 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; } }); });