2018-12-21 11:50:28 +00:00
|
|
|
const app = require(`${serviceRoot}/server/server`);
|
2018-10-15 09:29:17 +00:00
|
|
|
|
|
|
|
describe('order addToOrder()', () => {
|
2018-10-24 12:10:08 +00:00
|
|
|
let rowToDelete;
|
|
|
|
afterAll(async() => {
|
|
|
|
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 16});
|
|
|
|
});
|
|
|
|
|
2018-10-15 09:29:17 +00:00
|
|
|
it('should add a row to a given order', async() => {
|
|
|
|
let unmodifiedRows = await app.models.OrderRow.find({where: {orderFk: 16}});
|
|
|
|
|
|
|
|
expect(unmodifiedRows.length).toBe(4);
|
|
|
|
|
|
|
|
let params = {
|
|
|
|
orderFk: 16,
|
|
|
|
items: [{
|
|
|
|
itemFk: 1,
|
|
|
|
quantity: 1,
|
|
|
|
warehouseFk: 1
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
|
|
|
await app.models.OrderRow.addToOrder(params);
|
|
|
|
|
|
|
|
let modifiedRows = await app.models.OrderRow.find({where: {orderFk: 16}});
|
|
|
|
|
2018-10-24 12:10:08 +00:00
|
|
|
rowToDelete = modifiedRows[modifiedRows.length - 1].id;
|
|
|
|
|
2018-10-15 09:29:17 +00:00
|
|
|
expect(modifiedRows.length).toBe(5);
|
|
|
|
});
|
|
|
|
});
|