const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('ticket deleteExpeditions()', () => { let ctx; beforeAll(async() => { ctx = { accessToken: {userId: 9}, req: { headers: {origin: 'http://localhost'} } }; spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: ctx }); }); it('should delete the selected expeditions', async() => { const tx = await models.Expedition.beginTransaction({}); try { const options = {transaction: tx}; const expeditionIds = [12, 13]; const result = await models.Expedition.deleteExpeditions(ctx, expeditionIds, options); expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });