2023-07-27 05:58:55 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
|
|
|
|
|
|
|
describe('sale-tracking delete()', () => {
|
|
|
|
it('should delete a row of saleTracking and itemShelvingSale', async() => {
|
|
|
|
const tx = await models.SaleTracking.beginTransaction({});
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const itemShelvingsBefore = await models.ItemShelvingSale.find(null, options);
|
|
|
|
const saleTrackingsBefore = await models.SaleTracking.find(null, options);
|
|
|
|
|
|
|
|
const saleFk = 1;
|
2024-03-14 07:36:19 +00:00
|
|
|
const stateCode = ['PREPARED'];
|
|
|
|
await models.SaleTracking.delete(saleFk, stateCode, options);
|
2023-07-27 05:58:55 +00:00
|
|
|
|
|
|
|
const itemShelvingsAfter = await models.ItemShelvingSale.find(null, options);
|
|
|
|
const saleTrackingsAfter = await models.SaleTracking.find(null, options);
|
|
|
|
|
|
|
|
expect(saleTrackingsAfter.length).toBeLessThan(saleTrackingsBefore.length);
|
|
|
|
expect(itemShelvingsAfter.length).toBeLessThan(itemShelvingsBefore.length);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|