@@ -1297,9 +1297,9 @@ describe('ListBox', () => {
1297
1297
let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange} ) ;
1298
1298
let items = getAllByRole ( 'option' ) ;
1299
1299
1300
- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1300
+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1301
1301
expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1302
-
1302
+
1303
1303
await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
1304
1304
expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1305
1305
} ) ;
@@ -1309,9 +1309,9 @@ describe('ListBox', () => {
1309
1309
let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange, shouldSelectOnPressUp : false } ) ;
1310
1310
let items = getAllByRole ( 'option' ) ;
1311
1311
1312
- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1312
+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1313
1313
expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1314
-
1314
+
1315
1315
await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
1316
1316
expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1317
1317
} ) ;
@@ -1321,11 +1321,40 @@ describe('ListBox', () => {
1321
1321
let { getAllByRole} = renderListbox ( { selectionMode : 'single' , onSelectionChange, shouldSelectOnPressUp : true } ) ;
1322
1322
let items = getAllByRole ( 'option' ) ;
1323
1323
1324
- await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1324
+ await user . pointer ( { target : items [ 0 ] , keys : '[MouseLeft>]' } ) ;
1325
1325
expect ( onSelectionChange ) . toBeCalledTimes ( 0 ) ;
1326
-
1326
+
1327
1327
await user . pointer ( { target : items [ 0 ] , keys : '[/MouseLeft]' } ) ;
1328
1328
expect ( onSelectionChange ) . toBeCalledTimes ( 1 ) ;
1329
1329
} ) ;
1330
1330
} ) ;
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
+ } ) ;
1331
1360
} ) ;
0 commit comments