fix: add token invalid case in reset password. (#691)

This commit is contained in:
Attiya Ishaque
2022-12-06 17:09:32 +05:00
committed by GitHub
parent 7d536e6cdb
commit 762da62a29
2 changed files with 21 additions and 0 deletions

View File

@@ -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));
}

View File

@@ -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: {