30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
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;
|
|
const stateCode = ['PREPARED'];
|
|
await models.SaleTracking.delete(saleFk, stateCode, options);
|
|
|
|
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;
|
|
}
|
|
});
|
|
});
|