Skip to content

Commit

Permalink
Add missing capture events unit tests (skipped for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Jun 20, 2024
1 parent b0ba57e commit fbc8472
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ describe.each( [
} )
);

// NOTE: legacy CustomSelectControl doesn't fire onChange
// at this point in time.
expect( mockOnChange ).toHaveBeenNthCalledWith(
1,
expect.objectContaining( {
Expand Down Expand Up @@ -351,6 +353,33 @@ describe.each( [
} );

describe( 'Keyboard behavior and accessibility', () => {
// skip reason: legacy v2 doesn't currently implement this behavior
it.skip( 'Captures the keypress event and does not let it propagate', async () => {
const onKeyDown = jest.fn();

render(
<div
// This role="none" is required to prevent an eslint warning about accessibility.
role="none"
onKeyDown={ onKeyDown }
>
<Component { ...legacyProps } />
</div>
);
const currentSelectedItem = screen.getByRole( 'combobox', {
expanded: false,
} );
await click( currentSelectedItem );

const customSelect = screen.getByRole( 'listbox', {
name: 'label!',
} );
expect( customSelect ).toHaveFocus();
await press.Enter();

expect( onKeyDown ).toHaveBeenCalledTimes( 0 );
} );

it( 'Should be able to change selection using keyboard', async () => {
render( <Component { ...legacyProps } /> );

Expand Down

0 comments on commit fbc8472

Please sign in to comment.