Skip to content

Commit

Permalink
Add additional assertions for focus
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Dec 7, 2023
1 parent 220e01f commit cc7f225
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/components/src/custom-select-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ describe.each( [
expect( currentSelectedItem ).toHaveFocus();

await user.keyboard( '{enter}' );
expect(
screen.getByRole( 'listbox', {
name: 'label!',
} )
).toHaveFocus();

await user.keyboard( '{arrowdown}' );
await user.keyboard( '{enter}' );

Expand All @@ -295,9 +301,14 @@ describe.each( [

await user.tab();
await user.keyboard( '{enter}' );
expect(
screen.getByRole( 'listbox', {
name: 'label!',
} )
).toHaveFocus();

await user.keyboard( '{a}' );
await user.keyboard( '{enter}' );

expect( currentSelectedItem ).toHaveTextContent( 'amber' );
} );

Expand All @@ -311,10 +322,19 @@ describe.each( [
} );

await user.tab();
expect( currentSelectedItem ).toHaveFocus();

await user.keyboard( '{a}' );
await user.keyboard( '{q}' );
await user.keyboard( '{enter}' );

expect(
screen.queryByRole( 'listbox', {
name: 'label!',
hidden: true,
} )
).not.toBeInTheDocument();

await user.keyboard( '{enter}' );
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );
} );

Expand Down

0 comments on commit cc7f225

Please sign in to comment.