26 lines
829 B
JavaScript
26 lines
829 B
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('setQuantitySale()', () => {
|
|
it('should change quantity sale', async() => {
|
|
const tx = await models.Sale.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
const saleId = 30;
|
|
const newQuantity = 5;
|
|
const originalSale = await models.Sale.findById(saleId);
|
|
|
|
await models.Collection.setQuantitySale(saleId, newQuantity, options);
|
|
const updateSale = await models.Sale.findById(saleId);
|
|
|
|
expect(updateSale.quantity).toBeLessThan(originalSale.quantity);
|
|
expect(updateSale.quantity).toEqual(newQuantity);
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|