salix/modules/item/back/methods/item-shelving/specs/updateFromSale.spec.js

23 lines
832 B
JavaScript
Raw Normal View History

2024-03-14 07:36:19 +00:00
const {models} = require('vn-loopback/server/server');
describe('itemShelving updateFromSale()', () => {
it('should update the quantity', async() => {
const tx = await models.ItemBarcode.beginTransaction({});
const options = {transaction: tx};
const saleFk = 2;
2024-11-13 10:51:23 +00:00
const filter = {where: {itemFk: 4, shelvingFk: 12}
2024-03-14 07:36:19 +00:00
};
try {
const {visible: visibleBefore} = await models.ItemShelving.findOne(filter, options);
await models.ItemShelving.updateFromSale(saleFk, options);
const {visible: visibleAfter} = await models.ItemShelving.findOne(filter, options);
expect(visibleAfter).toEqual(visibleBefore + 5);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});