const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); describe('VnUser recoverPassword()', () => { const userId = 1107; const activeCtx = { accessToken: {userId: userId}, http: { req: { headers: {origin: 'http://localhost'} } } }; beforeEach(() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); }); it('should send email with token', async() => { const userId = 1107; const user = await models.VnUser.findById(userId); await models.VnUser.recoverPassword(user.email); const result = await models.AccessToken.findOne({where: {userId: userId}}); expect(result).toBeDefined(); }); });