Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Nov 1, 2023
1 parent aff1df9 commit f2e1230
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/components/src/combobox-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ describe.each( [
it( 'should not filter the list of options if shouldFilter is false', async () => {
const user = await userEvent.setup();
const targetOption = timezones[ 0 ];
const japanTargetOption = timezones[ 12 ];
const onChangeSpy = jest.fn();
render(
<Component
Expand All @@ -232,10 +233,23 @@ describe.each( [
// Type enough characters to ensure a predictable search result
await user.keyboard( 'Japan' );

// Select first item (which should be Japan because the items are ordered)
await user.keyboard( '{ArrowDown}' );

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

expect( onChangeSpy ).toHaveBeenCalledTimes( 1 );
expect( onChangeSpy ).toHaveBeenCalledWith( japanTargetOption.value );
expect( input ).toHaveValue( japanTargetOption.label );

// Select first item (which should be Japan because the items are ordered)
await user.keyboard( '{ArrowDown}' );

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

expect( onChangeSpy ).toHaveBeenCalledTimes( 2 );
expect( onChangeSpy ).toHaveBeenCalledWith( targetOption.value );
expect( input ).toHaveValue( targetOption.label );
} );
Expand Down

0 comments on commit f2e1230

Please sign in to comment.