Skip to content

Commit

Permalink
Fix: Improved Code Coverage in src/screens/ForgotPassword/ForgotPassw…
Browse files Browse the repository at this point in the history
…ord.tsx
  • Loading branch information
PratapRathi committed Jan 1, 2025
1 parent 81a8a33 commit a780007
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
25 changes: 22 additions & 3 deletions src/screens/ForgotPassword/ForgotPassword.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { I18nextProvider } from 'react-i18next';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import { toast } from 'react-toastify';
import { GENERATE_OTP_MUTATION } from 'GraphQl/Mutations/mutations';
import {
FORGOT_PASSWORD_MUTATION,
GENERATE_OTP_MUTATION,
} from 'GraphQl/Mutations/mutations';
import { store } from 'state/store';
import { StaticMockLink } from 'utils/StaticMockLink';
// import i18nForTest from 'utils/i18nForTest';
Expand All @@ -26,6 +29,22 @@ vi.mock('react-toastify', () => ({
}));

const MOCKS = [
{
request: {
query: FORGOT_PASSWORD_MUTATION,
variables: {
otpToken: 'lorem ipsum',
userOtp: '12345',
newPassword: 'johnDoe@12345',
},
},
result: {
data: {
forgotPassword: true,
},
},
},

{
request: {
query: GENERATE_OTP_MUTATION,
Expand Down Expand Up @@ -173,8 +192,8 @@ describe('Testing Forgot Password screen', () => {
it('Testing forgot password functionality', async () => {
const formData = {
userOtp: '12345',
newPassword: 'johnDoe',
confirmNewPassword: 'johnDoe',
newPassword: 'johnDoe@12345',
confirmNewPassword: 'johnDoe@12345',
email: '[email protected]',
};

Expand Down
3 changes: 1 addition & 2 deletions src/screens/ForgotPassword/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const ForgotPassword = (): JSX.Element => {
},
});

/* istanbul ignore next */
/* istanbul ignore else -- @preserve */
if (data) {
toast.success(t('passwordChanges') as string);
setShowEnterEmail(true);
Expand All @@ -147,7 +147,6 @@ const ForgotPassword = (): JSX.Element => {
}
} catch (error: unknown) {
setShowEnterEmail(true);
/* istanbul ignore next */
errorHandler(t, error);
}
};
Expand Down

0 comments on commit a780007

Please sign in to comment.