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