Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Jan 6, 2024
1 parent 53b3a46 commit ac7e43b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
52 changes: 48 additions & 4 deletions src/screens/LoginPage/LoginPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ describe('Testing Login Page Screen', () => {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
password: 'johndoe',
confirmPassword: 'johndoe',
password: 'John@123',
confirmPassword: 'John@123',
};

render(
Expand Down Expand Up @@ -215,13 +215,57 @@ describe('Testing Login Page Screen', () => {
userEvent.click(screen.getByTestId('registrationBtn'));
});

test('Testing registration functionality when all inputs are invalid', async () => {
const formData = {
firstName: '1234',
lastName: '8890',
email: '[email protected]',
password: 'john@123',
confirmPassword: 'john@123',
};

render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<LoginPage />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>
);

await wait();

userEvent.click(screen.getByTestId(/goToRegisterPortion/i));

await wait();

userEvent.type(
screen.getByPlaceholderText(/First Name/i),
formData.firstName
);
userEvent.type(
screen.getByPlaceholderText(/Last name/i),
formData.lastName
);
userEvent.type(screen.getByTestId(/signInEmail/i), formData.email);
userEvent.type(screen.getByPlaceholderText('Password'), formData.password);
userEvent.type(
screen.getByPlaceholderText('Confirm Password'),
formData.confirmPassword
);
userEvent.click(screen.getByTestId('registrationBtn'));
});

test('Testing registration functionality, when password and confirm password is not same', async () => {
const formData = {
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
password: 'johndoe',
confirmPassword: 'doeJohn',
password: 'johnDoe@1',
confirmPassword: 'doeJohn@2',
};

render(
Expand Down
2 changes: 1 addition & 1 deletion src/screens/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function loginPage(): JSX.Element {
/^[a-zA-Z]+$/.test(value);

const validatePassword = (password: string): boolean => {
const lengthCheck = new RegExp('^.{7,}$');
const lengthCheck = new RegExp('^.{6,}$');
return (
lengthCheck.test(password) &&
passwordValidationRegExp.lowercaseCharRegExp.test(password) &&
Expand Down

0 comments on commit ac7e43b

Please sign in to comment.