Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasfoo committed Dec 6, 2024
1 parent 4fe5873 commit 158aca2
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions client/blocks/login/test/lost-password-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe( 'LostPasswordForm', () => {
test( 'displays a lost password form without errors', () => {
render( <LostPasswordForm redirectToAfterLoginUrl="" oauth2ClientId="" locale="" /> );

const email = screen.getByLabelText( /Your email address/i );
const email = screen.getByLabelText( /Your email/i );
expect( email ).toBeInTheDocument();

const btn = screen.getByRole( 'button', { name: /Reset my password/i } );
Expand All @@ -27,10 +27,7 @@ describe( 'LostPasswordForm', () => {
test( 'displays an error message when email is invalid', async () => {
render( <LostPasswordForm redirectToAfterLoginUrl="" oauth2ClientId="" locale="" /> );

await userEvent.type(
screen.getByRole( 'textbox', { name: 'Your email address' } ),
'invalid email'
);
await userEvent.type( screen.getByRole( 'textbox', { name: 'Your email' } ), 'invalid email' );
// The error message is displayed after the user blurs the input.
userEvent.tab();

Expand All @@ -46,7 +43,7 @@ describe( 'LostPasswordForm', () => {
render( <LostPasswordForm redirectToAfterLoginUrl="" oauth2ClientId="" locale="" /> );

await userEvent.type(
screen.getByRole( 'textbox', { name: 'Your email address' } ),
screen.getByRole( 'textbox', { name: 'Your email' } ),
'user@example.com'
);
// The error message is displayed after the user blurs the input.
Expand All @@ -59,15 +56,12 @@ describe( 'LostPasswordForm', () => {
test( 'reset error message when email is valid', async () => {
render( <LostPasswordForm redirectToAfterLoginUrl="" oauth2ClientId="" locale="" /> );

await userEvent.type(
screen.getByRole( 'textbox', { name: 'Your email address' } ),
'invalid email'
);
await userEvent.type( screen.getByRole( 'textbox', { name: 'Your email' } ), 'invalid email' );
// The error message is displayed after the user blurs the input.
userEvent.tab();

await userEvent.type(
screen.getByRole( 'textbox', { name: 'Your email address' } ),
screen.getByRole( 'textbox', { name: 'Your email' } ),
'user@example.com'
);
// The error message is displayed after the user blurs the input.
Expand All @@ -81,14 +75,11 @@ describe( 'LostPasswordForm', () => {
test( 'reset error message when email is empty', async () => {
render( <LostPasswordForm redirectToAfterLoginUrl="" oauth2ClientId="" locale="" /> );

await userEvent.type(
screen.getByRole( 'textbox', { name: 'Your email address' } ),
'invalid email'
);
await userEvent.type( screen.getByRole( 'textbox', { name: 'Your email' } ), 'invalid email' );
// The error message is displayed after the user blurs the input.
userEvent.tab();

await userEvent.clear( screen.getByRole( 'textbox', { name: 'Your email address' } ) );
await userEvent.clear( screen.getByRole( 'textbox', { name: 'Your email' } ) );
// The error message is displayed after the user blurs the input.
userEvent.tab();

Expand Down

0 comments on commit 158aca2

Please sign in to comment.