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'];
|
2023-07-27 05:58:55 +00:00
|
|
|
const result = await models.SaleTracking.delete(saleFk, stateCode, options);
|
|
|
|
|
|
|
|
const itemShelvingsAfter = await models.ItemShelvingSale.find(null, options);
|
|
|
|
const saleTrackingsAfter = await models.SaleTracking.find(null, options);
|
|
|
|
|
|
|
|
expect(result).toEqual(true);
|
|
|
|
expect(saleTrackingsAfter.length).toBeLessThan(saleTrackingsBefore.length);
|
|
|
|
expect(itemShelvingsAfter.length).toBeLessThan(itemShelvingsBefore.length);
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|