salix/back/models/specs/user.spec.js

33 lines
847 B
JavaScript
Raw Permalink Normal View History

2022-11-09 13:51:30 +00:00
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('VnUser recoverPassword()', () => {
2022-11-09 13:51:30 +00:00
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);
2022-11-09 13:51:30 +00:00
await models.VnUser.recoverPassword(user.email);
2022-11-09 13:51:30 +00:00
const result = await models.AccessToken.findOne({where: {userId: userId}});
expect(result).toBeDefined();
});
});