diff --git a/src/reset-password/data/sagas.js b/src/reset-password/data/sagas.js index 185670e2..4213cc55 100644 --- a/src/reset-password/data/sagas.js +++ b/src/reset-password/data/sagas.js @@ -45,6 +45,8 @@ export function* handleResetPassword(action) { if (resetStatus) { yield put(resetPasswordSuccess(resetStatus)); + } else if (data.token_invalid) { + yield put(passwordResetFailure(PASSWORD_RESET.INVALID_TOKEN)); } else { yield put(resetPasswordFailure(PASSWORD_VALIDATION_ERROR, resetErrors)); } diff --git a/src/reset-password/data/tests/sagas.test.js b/src/reset-password/data/tests/sagas.test.js index 48618572..c2fbaa0a 100644 --- a/src/reset-password/data/tests/sagas.test.js +++ b/src/reset-password/data/tests/sagas.test.js @@ -76,6 +76,25 @@ describe('handleResetPassword', () => { resetPassword.mockClear(); }); + it('should call service and dispatch invalid token error', async () => { + responseData.reset_status = false; + responseData.token_invalid = true; + + const resetPassword = jest.spyOn(api, 'resetPassword') + .mockImplementation(() => Promise.resolve(responseData)); + + const dispatched = []; + await runSaga( + { dispatch: (action) => dispatched.push(action) }, + handleResetPassword, + params, + ); + + expect(resetPassword).toHaveBeenCalledTimes(1); + expect(dispatched).toEqual([resetPasswordBegin(), passwordResetFailure(PASSWORD_RESET.INVALID_TOKEN)]); + resetPassword.mockClear(); + }); + it('should call service and dispatch ratelimit error', async () => { const errorResponse = { response: {