diff --git a/src/reset-password/data/constants.js b/src/reset-password/data/constants.js
index 6f50fcf7..e5ce291a 100644
--- a/src/reset-password/data/constants.js
+++ b/src/reset-password/data/constants.js
@@ -6,6 +6,7 @@ export const TOKEN_STATE = {
// password reset error codes
export const FORM_SUBMISSION_ERROR = 'form-submission-error';
export const PASSWORD_RESET_ERROR = 'password-reset-error';
+export const SUCCESS = 'success';
export const PASSWORD_VALIDATION_ERROR = 'password-validation-failure';
export const PASSWORD_RESET = {
diff --git a/src/reset-password/tests/ResetPasswordPage.test.jsx b/src/reset-password/tests/ResetPasswordPage.test.jsx
index 0f39dbe4..d2795f28 100644
--- a/src/reset-password/tests/ResetPasswordPage.test.jsx
+++ b/src/reset-password/tests/ResetPasswordPage.test.jsx
@@ -10,8 +10,10 @@ import { MemoryRouter, Router } from 'react-router-dom';
import configureStore from 'redux-mock-store';
import { LOGIN_PAGE } from '../../data/constants';
-import { resetPassword } from '../data/actions';
-import { PASSWORD_RESET, TOKEN_STATE } from '../data/constants';
+import { resetPassword, validateToken } from '../data/actions';
+import {
+ PASSWORD_RESET, PASSWORD_RESET_ERROR, SUCCESS, TOKEN_STATE,
+} from '../data/constants';
import ResetPasswordPage from '../ResetPasswordPage';
jest.mock('@edx/frontend-platform/auth');
@@ -158,6 +160,64 @@ describe('ResetPasswordPage', () => {
// ******** miscellaneous tests ********
+ it('should call validation on password field when blur event fires', () => {
+ const resetPasswordPage = mount(reduxWrapper());
+ const expectedText = 'Password criteria has not been metPassword must contain at least 8 characters, at least one letter, and at least one number';
+ resetPasswordPage.find('input#newPassword').simulate('change', { target: { value: 'aziz156', name: 'newPassword' } });
+ resetPasswordPage.find('input#newPassword').simulate('blur', { target: { value: 'aziz156', name: 'newPassword' } });
+ expect(resetPasswordPage.find('div[feedback-for="newPassword"]').text()).toEqual(expectedText);
+ });
+ it('should not call validation when typing and click on show icon button', () => {
+ const resetPasswordPage = mount(reduxWrapper());
+ resetPasswordPage.find('input#newPassword').simulate('change', { target: { value: 'aziz156@', name: 'newPassword' } });
+ resetPasswordPage.find('button[aria-label="Show password"]').at(0).simulate('click');
+ resetPasswordPage.find('button[aria-label="Hide password"]').at(0).simulate('blur');
+ expect(resetPasswordPage.find('div[feedback-for="newPassword"]').exists()).toBe(false);
+ });
+ it('should call validation click on show icon button and then focus out', () => {
+ const resetPasswordPage = mount(reduxWrapper());
+ resetPasswordPage.find('input#newPassword').simulate('focus', { target: { value: 'aziz156@', name: 'newPassword' } });
+ resetPasswordPage.find('input#newPassword').simulate('blur', { relatedTarget: { name: 'password' } });
+ resetPasswordPage.find('button[aria-label="Show password"]').at(0).simulate('click');
+ expect(resetPasswordPage.find('div[feedback-for="newPassword"]').exists()).toBe(false);
+ });
+ it('show spinner when api call is pending', () => {
+ store.dispatch = jest.fn(store.dispatch);
+ props = {
+ status:
+ TOKEN_STATE.PENDING,
+ match: {
+ params: { token: '1c-bmjdkc-5e60e084cf8113048ca7' },
+ },
+ };
+ mount(reduxWrapper());
+ expect(store.dispatch).toHaveBeenCalledWith(validateToken(props.match.params.token));
+ });
+ it('should redirect the user to Reset password email screen ', async () => {
+ props = {
+ status:
+ PASSWORD_RESET_ERROR,
+ };
+ mount(reduxWrapper(
+
+
+ ,
+
+ ));
+ expect(history.location.pathname).toEqual('/reset');
+ });
+ it('should redirect the user to root url of the application ', async () => {
+ props = {
+ status: SUCCESS,
+ };
+ mount(reduxWrapper(
+
+
+ ,
+ ));
+ expect(history.location.pathname).toEqual('/login');
+ });
+
it('check cookie rendered', () => {
const resetPasswordPage = mount(reduxWrapper());
expect(resetPasswordPage.find()).toBeTruthy();