@@ -1297,9 +1297,9 @@ describe('ListBox', () => {
12971297 let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange} ) ;
12981298 let items = getAllByRole ( 'option' ) ;
12991299
1300- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1300+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
13011301 expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1302-
1302+
13031303 await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
13041304 expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
13051305 } ) ;
@@ -1309,9 +1309,9 @@ describe('ListBox', () => {
13091309 let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange, shouldSelectOnPressUp : false } ) ;
13101310 let items = getAllByRole ( 'option' ) ;
13111311
1312- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1312+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
13131313 expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1314-
1314+
13151315 await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
13161316 expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
13171317 } ) ;
@@ -1321,11 +1321,40 @@ describe('ListBox', () => {
13211321 let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange, shouldSelectOnPressUp : true } ) ;
13221322 let items = getAllByRole ( 'option' ) ;
13231323
1324- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1324+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
13251325 expect ( onSelectionChange ) . toBeCalledTimes ( 0 ) ;
1326-
1326+
13271327 await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
13281328 expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
13291329 } ) ;
13301330 } ) ;
1331+
1332+ describe ( 'shouldFocusOnHover' , ( ) => {
1333+ it ( 'should focus options on hovering with shouldFocusOnHover' , async ( ) => {
1334+ let { getAllByRole} = renderListbox ( { shouldFocusOnHover : true } ) ;
1335+ let options = getAllByRole ( 'option' ) ;
1336+ let option1 = options [ 0 ] ;
1337+ let option2 = options [ 1 ] ;
1338+
1339+ expect ( option1 ) . not . toHaveFocus ( ) ;
1340+ expect ( option2 ) . not . toHaveFocus ( ) ;
1341+
1342+ await user . hover ( option1 ) ;
1343+ expect ( option1 ) . toHaveFocus ( ) ;
1344+
1345+ keyPress ( 'ArrowDown' ) ;
1346+ expect ( option1 ) . not . toHaveFocus ( ) ;
1347+ expect ( option2 ) . toHaveFocus ( ) ;
1348+ } ) ;
1349+
1350+ it . each ( [ false , undefined ] ) ( 'should not focus options on hovering when shouldFocusOnHover is not true' , async ( shouldFocusOnHover ) => {
1351+ let { getAllByRole} = renderListbox ( { shouldFocusOnHover} ) ;
1352+ let option = getAllByRole ( 'option' ) [ 0 ] ;
1353+
1354+ expect ( option ) . not . toHaveFocus ( ) ;
1355+
1356+ await user . hover ( option ) ;
1357+ expect ( option ) . not . toHaveFocus ( ) ;
1358+ } ) ;
1359+ } ) ;
13311360} ) ;
0 commit comments