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 }) => {
28
28
key = { i }
29
29
id = { `menu-item-${ i + 1 } ` }
30
30
onClick = { clickHandlers [ i ] }
31
- onMouseEnter = { ( ) : void => moveFocus ( i ) }
32
31
href = { i > 1 ? 'https://example.com' : undefined }
33
32
>
34
33
{ i + 1 } Item
@@ -46,6 +45,10 @@ const TestComponent: React.FC<Props> = ({ options }) => {
46
45
Add Item
47
46
</ button >
48
47
48
+ < button data-testid = 'focus-third-item' onClick = { ( ) : void => moveFocus ( 2 ) } >
49
+ Focus third item
50
+ </ button >
51
+
49
52
< span data-testid = 'is-open-indicator' > { isOpen ? 'true' : 'false' } </ span >
50
53
</ React . Fragment >
51
54
) ;
@@ -542,7 +545,7 @@ it('Moves the focus to the menu item with a label that starts with the correspon
542
545
expect ( screen . getByText ( '3 Item' ) ) . toHaveFocus ( ) ;
543
546
} ) ;
544
547
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 ' , ( ) => {
546
549
render ( < TestComponent /> ) ;
547
550
548
551
userEvent . tab ( ) ;
@@ -551,13 +554,7 @@ it('Moves the focus to the menu item currently hovered over by mouse', () => {
551
554
skipClick : true ,
552
555
} ) ;
553
556
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' ) ) ;
561
558
562
559
expect ( screen . getByText ( '3 Item' ) ) . toHaveFocus ( ) ;
563
560
} ) ;
You can’t perform that action at this time.
0 commit comments