File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ const TestComponent: React.FC<Props> = ({ options }) => {
2828 key = { i }
2929 id = { `menu-item-${ i + 1 } ` }
3030 onClick = { clickHandlers [ i ] }
31- onMouseEnter = { ( ) : void => moveFocus ( i ) }
3231 href = { i > 1 ? 'https://example.com' : undefined }
3332 >
3433 { i + 1 } Item
@@ -46,6 +45,10 @@ const TestComponent: React.FC<Props> = ({ options }) => {
4645 Add Item
4746 </ button >
4847
48+ < button data-testid = 'focus-third-item' onClick = { ( ) : void => moveFocus ( 2 ) } >
49+ Focus third item
50+ </ button >
51+
4952 < span data-testid = 'is-open-indicator' > { isOpen ? 'true' : 'false' } </ span >
5053 </ React . Fragment >
5154 ) ;
@@ -542,7 +545,7 @@ it('Moves the focus to the menu item with a label that starts with the correspon
542545 expect ( screen . getByText ( '3 Item' ) ) . toHaveFocus ( ) ;
543546} ) ;
544547
545- it ( 'Moves the focus to the menu item currently hovered over by mouse ' , ( ) => {
548+ it ( 'Moves the focus to the provided menu item when `moveFocus` is called ' , ( ) => {
546549 render ( < TestComponent /> ) ;
547550
548551 userEvent . tab ( ) ;
@@ -551,13 +554,7 @@ it('Moves the focus to the menu item currently hovered over by mouse', () => {
551554 skipClick : true ,
552555 } ) ;
553556
554- fireEvent (
555- screen . getByText ( '3 Item' ) ,
556- new MouseEvent ( 'mouseover' , {
557- bubbles : true ,
558- cancelable : true ,
559- } )
560- ) ;
557+ userEvent . click ( screen . getByTestId ( 'focus-third-item' ) ) ;
561558
562559 expect ( screen . getByText ( '3 Item' ) ) . toHaveFocus ( ) ;
563560} ) ;
You can’t perform that action at this time.
0 commit comments