Skip to content

Commit

Permalink
add selection announcement test
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 committed Jul 27, 2022
1 parent e1ad9d5 commit 1db34a1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/components/src/combobox-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,32 @@ describe.each( [
expect( input ).toHaveValue( targetOption.label );
} );

it( 'should render aria-live announcement upon selection', async () => {
const user = setupUser();
const targetOption = setTargetOption( 9 );
const onChangeSpy = jest.fn();
render(
<Component
options={ timezones }
label={ defaultLabelText }
onChange={ onChangeSpy }
/>
);

// Pressing tab selects the input and shows the options
await user.tab();

// Type enough characters to ensure a predictable search result
await user.keyboard( targetOption.searchString );

// Pressing Enter/Return selects the currently focused option
await user.keyboard( '{Enter}' );

const itemSelectedAnnouncement = screen.getByText( 'Item selected.' );

expect( itemSelectedAnnouncement ).toBeInTheDocument();
} );

it( 'should process multiple entries in a single session', async () => {
const user = setupUser();
const unmatchedString = 'Mordor';
Expand Down

0 comments on commit 1db34a1

Please sign in to comment.