const {models} = require('vn-loopback/server/server'); describe('itemBarcode delete()', () => { it('should delete a record by itemFk and code', async() => { const tx = await models.ItemBarcode.beginTransaction({}); const options = {transaction: tx}; const itemFk = 1; const code = 1111111111; try { const itemsBarcodeBefore = await models.ItemBarcode.find({}, options); await models.ItemBarcode.delete(code, itemFk, options); const itemsBarcodeAfter = await models.ItemBarcode.find({}, options); expect(itemsBarcodeBefore.length).toBeGreaterThan(itemsBarcodeAfter.length); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });