salix/modules/item/back/methods/item/specs/getWasteByItem.spec.js

25 lines
838 B
JavaScript

const models = require('vn-loopback/server/server').models;
describe('Item getWasteByItem()', () => {
it('should check for the waste breakdown by worker and item', async() => {
const tx = await models.Item.beginTransaction({});
const options = {transaction: tx};
try {
const result = await models.Item.getWasteByItem('buyer', 'Crisantemo', options);
const length = result.length;
const anyResult = result[Math.floor(Math.random() * Math.floor(length))];
expect(anyResult.buyer).toEqual('buyer');
expect(anyResult.family).toEqual('Crisantemo');
expect(anyResult.lines.length).toBeGreaterThanOrEqual(2);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
});
});