Skip to content

Commit

Permalink
Add label and adjust listbox queries
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Dec 7, 2023
1 parent 8db564a commit 220e01f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/components/src/custom-select-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CustomSelectControl from '..';
const customClass = 'amber-skies';

const props = {
label: 'label!',
options: [
{
key: 'flower1',
Expand Down Expand Up @@ -107,11 +108,17 @@ describe.each( [
await user.tab();
await user.keyboard( '{enter}' );
expect(
screen.getByRole( 'listbox', { hidden: false } )
screen.getByRole( 'listbox', {
name: 'label!',
} )
).toBeVisible();

await user.keyboard( '{escape}' );
expect( screen.queryByRole( 'listbox' ) ).not.toBeInTheDocument();
expect(
screen.queryByRole( 'listbox', {
name: 'label!',
} )
).not.toBeInTheDocument();

expect( currentSelectedItem ).toHaveTextContent(
props.options[ 0 ].name
Expand Down Expand Up @@ -250,7 +257,9 @@ describe.each( [
} );
await user.click( currentSelectedItem );

const customSelect = screen.getByRole( 'listbox' );
const customSelect = screen.getByRole( 'listbox', {
name: 'label!',
} );
await user.type( customSelect, '{enter}' );

expect( onKeyDown ).toHaveBeenCalledTimes( 0 );
Expand Down

0 comments on commit 220e01f

Please sign in to comment.