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-01-17 09:18:13 +00:00
|
|
|
const stateCode = ['PREPARED'];
|
2024-01-31 12:11:15 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|