Skip to content

Commit

Permalink
fix(users): unit test for password reset 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreBrisorgueil committed Sep 10, 2020
1 parent 4ed570e commit 0d75a52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/users/controllers/users/users.password.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ exports.reset = async (req, res) => {
return res.status(200)
.cookie('TOKEN', jwt.sign({ userId: user.id }, configuration.jwt.secret, { expiresIn: config.jwt.expiresIn }), { httpOnly: true })
.json({
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Sign in',
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Password changed successfully',
});
} catch (err) {
responses.error(res, 422, 'Unprocessable Entity', errors.getMessage(err))(err);
Expand Down Expand Up @@ -131,7 +131,7 @@ exports.updatePassword = async (req, res) => {
return res.status(200)
.cookie('TOKEN', jwt.sign({ userId: user.id }, configuration.jwt.secret, { expiresIn: config.jwt.expiresIn }), { httpOnly: true })
.json({
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Sign in',
user, tokenExpiresIn: Date.now() + (config.jwt.expiresIn * 1000), type: 'sucess', message: 'Password changed successfully',
});
} catch (err) {
responses.error(res, 422, 'Unprocessable Entity', errors.getMessage(err))(err);
Expand Down
4 changes: 2 additions & 2 deletions modules/users/tests/user.crud.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ describe('User CRUD Tests :', () => {
try {
const result2 = await agent.get(`/api/auth/reset/${result.resetPasswordToken}`)
.expect(302);
expect(result2.headers.location).toBe(`/password/reset/${result.resetPasswordToken}`);
expect(result2.headers.location).toBe(`/api/password/reset/${result.resetPasswordToken}`);
} catch (err) {
console.log(err);
expect(err).toBeFalsy();
Expand Down Expand Up @@ -541,7 +541,7 @@ describe('User CRUD Tests :', () => {
const invalidToken = 'someTOKEN1234567890';
const result2 = await agent.get(`/api/auth/reset/${invalidToken}`)
.expect(302);
expect(result2.headers.location).toBe('/password/reset/invalid');
expect(result2.headers.location).toBe('/api/password/reset/invalid');
} catch (err) {
console.log(err);
expect(err).toBeFalsy();
Expand Down

0 comments on commit 0d75a52

Please sign in to comment.