2024-01-17 14:26:04 +00:00
|
|
|
const {models} = require('vn-loopback/server/server');
|
|
|
|
|
2024-01-18 10:51:21 +00:00
|
|
|
describe('itemBarcode delete()', () => {
|
2024-01-17 14:26:04 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|