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

32 lines
868 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()', () => {
let rowToDelete;
afterAll(async() => {
2019-02-13 12:19:15 +00:00
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 20});
});
2018-10-15 09:29:17 +00:00
it('should add a row to a given order', async() => {
2019-02-13 12:19:15 +00:00
let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: 20}});
2018-10-15 09:29:17 +00:00
2019-02-13 12:19:15 +00:00
expect(unmodifiedRows.length).toBe(1);
2018-10-15 09:29:17 +00:00
let params = {
2019-02-13 12:19:15 +00:00
orderFk: 20,
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-02-13 12:19:15 +00:00
let modifiedRows = await app.models.OrderRow.find({where: {orderFk: 20}});
2018-10-15 09:29:17 +00:00
rowToDelete = modifiedRows[modifiedRows.length - 1].id;
2019-02-13 12:19:15 +00:00
expect(modifiedRows.length).toBe(2);
2018-10-15 09:29:17 +00:00
});
});