const models = require('vn-loopback/server/server').models; describe('sale usesMana()', () => { const ctx = { req: { accessToken: {userId: 18} } }; it('should return that the worker uses mana', async() => { const tx = await models.Sale.beginTransaction({}); try { const options = {transaction: tx}; const teamOne = 96; const userId = ctx.req.accessToken.userId; const business = await models.Business.findOne({where: {workerFk: userId}}, options); await business.updateAttribute('departmentFk', teamOne, options); const usesMana = await models.Sale.usesMana(ctx, options); expect(usesMana).toBe(true); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should return that the worker not uses mana', async() => { const tx = await models.Sale.beginTransaction({}); try { const options = {transaction: tx}; const usesMana = await models.Sale.usesMana(ctx, options); expect(usesMana).toBe(false); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });