salix/modules/order/back/methods/order-row/specs/addToOrder.spec.js

33 lines
911 B
JavaScript

const app = require('vn-loopback/server/server');
describe('order addToOrder()', () => {
const orderId = 8;
let rowToDelete;
afterAll(async() => {
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: orderId});
});
it('should add a row to a given order', async() => {
let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: orderId}});
expect(unmodifiedRows.length).toBe(2);
let params = {
orderFk: orderId,
items: [{
itemFk: 1,
quantity: 10,
warehouseFk: 1
}]
};
await app.models.OrderRow.addToOrder(params);
let modifiedRows = await app.models.OrderRow.find({where: {orderFk: orderId}});
rowToDelete = modifiedRows[modifiedRows.length - 1].id;
expect(modifiedRows.length).toBe(3);
});
});