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

33 lines
911 B
JavaScript
Raw Normal View History

2019-01-24 08:08:28 +00:00
const app = require('vn-loopback/server/server');
2018-10-15 09:29:17 +00:00
describe('order addToOrder()', () => {
2019-06-14 10:27:41 +00:00
const orderId = 8;
let rowToDelete;
afterAll(async() => {
2019-06-14 10:27:41 +00:00
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: orderId});
});
2018-10-15 09:29:17 +00:00
it('should add a row to a given order', async() => {
2019-06-14 10:27:41 +00:00
let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: orderId}});
2018-10-15 09:29:17 +00:00
2019-06-14 10:27:41 +00:00
expect(unmodifiedRows.length).toBe(2);
2018-10-15 09:29:17 +00:00
let params = {
2019-06-14 10:27:41 +00:00
orderFk: orderId,
2018-10-15 09:29:17 +00:00
items: [{
itemFk: 1,
quantity: 10,
2018-10-15 09:29:17 +00:00
warehouseFk: 1
}]
};
await app.models.OrderRow.addToOrder(params);
2019-06-14 10:27:41 +00:00
let modifiedRows = await app.models.OrderRow.find({where: {orderFk: orderId}});
2018-10-15 09:29:17 +00:00
rowToDelete = modifiedRows[modifiedRows.length - 1].id;
2019-06-14 10:27:41 +00:00
expect(modifiedRows.length).toBe(3);
2018-10-15 09:29:17 +00:00
});
});