From 4157431589ff993e7eeea9b3594d3348224e5b73 Mon Sep 17 00:00:00 2001 From: ksraj123 Date: Tue, 28 Jul 2020 21:26:34 +0530 Subject: [PATCH] fix failing test file user.test.js --- app/controllers/user.js | 6 +++--- test/user.test.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/user.js b/app/controllers/user.js index 8b3303a..5cc134d 100644 --- a/app/controllers/user.js +++ b/app/controllers/user.js @@ -129,7 +129,7 @@ module.exports = { notification.heading = 'Forgot password!' notification.content = 'Password successfully updated!' notification.tag = TAGS.UPDATE - notificationHelper.addToNotificationForUser(id, res, notification, next) + await notificationHelper.addToNotificationForUser(id, res, notification, next) return res.status(HttpStatus.OK).json({ updated: true }) } else { res.status(HttpStatus.BAD_REQUEST).json({ error: 'Token expired' }) @@ -184,7 +184,7 @@ module.exports = { notification.heading = 'Account activate!' notification.content = 'Account successfully activated!' notification.tag = TAGS.ACTIVATE - notificationHelper.addToNotificationForUser(user._id, res, notification, next) + await notificationHelper.addToNotificationForUser(user._id, res, notification, next) return res.status(HttpStatus.OK).json({ msg: 'Succesfully activated!' }) } } catch (Error) { @@ -266,7 +266,7 @@ module.exports = { notification.heading = 'New follower!' notification.content = `${req.user.name.firstName} started following you!` notification.tag = TAGS.FOLLOWER - notificationHelper.addToNotificationForUser(user._id, res, notification, next) + await notificationHelper.addToNotificationForUser(user._id, res, notification, next) const userData = await User.findById(req.user._id) .populate('followings', ['name.firstName', 'name.lastName', 'info.about.designation', '_id', 'isAdmin']) .populate('followers', ['name.firstName', 'name.lastName', 'info.about.designation', '_id', 'isAdmin']) diff --git a/test/user.test.js b/test/user.test.js index 04534ec..b1fa087 100644 --- a/test/user.test.js +++ b/test/user.test.js @@ -209,7 +209,7 @@ test('Should not delete profile of unauthenticated user', async () => { /** Forgot password request **/ test('Should send the request to change the password ', async () => { const response = await request(app) - .post('/user/password_reset') + .patch('/user/password_reset/request') .send({ email: `${testUser.email}` }) @@ -221,7 +221,7 @@ test('Should send the request to change the password ', async () => { /* Password update */ test('Should update the password ', async () => { await request(app) - .post(`/user/password_reset/${passwordToken}`) + .patch(`/user/password_reset/${passwordToken}`) .send({ password: 'newPassword', id: testUserId @@ -243,7 +243,7 @@ test('Should activate the account ', async (done) => { /* Get invite link */ test('Should generate an invite link and send', async () => { const response = await request(app) - .get('/user/invite') + .get('/user/invite?role=user') .set('Authorization', `Bearer ${testUser.tokens[0].token}`) .send() .expect(HttpStatus.OK) @@ -258,7 +258,7 @@ test('Should validate the invite link token ', async () => { await request(app) .get(`/user/invite/${inviteToken}`) .send() - .expect(HttpStatus.OK) + .expect(HttpStatus.MOVED_TEMPORARILY) }) /* Logout the user */