@@ -1481,6 +1481,7 @@ describe('Picker', function () {
1481
1481
< Item key = "one" > One</ Item >
1482
1482
< Item key = "two" > Two</ Item >
1483
1483
< Item key = "three" > Three</ Item >
1484
+ < Item key = "" > None</ Item >
1484
1485
</ Picker >
1485
1486
</ Provider >
1486
1487
) ;
@@ -1493,7 +1494,7 @@ describe('Picker', function () {
1493
1494
1494
1495
let listbox = getByRole ( 'listbox' ) ;
1495
1496
let items = within ( listbox ) . getAllByRole ( 'option' ) ;
1496
- expect ( items . length ) . toBe ( 3 ) ;
1497
+ expect ( items . length ) . toBe ( 4 ) ;
1497
1498
expect ( items [ 0 ] ) . toHaveTextContent ( 'One' ) ;
1498
1499
expect ( items [ 1 ] ) . toHaveTextContent ( 'Two' ) ;
1499
1500
expect ( items [ 2 ] ) . toHaveTextContent ( 'Three' ) ;
@@ -1517,6 +1518,22 @@ describe('Picker', function () {
1517
1518
1518
1519
expect ( document . activeElement ) . toBe ( picker ) ;
1519
1520
expect ( picker ) . toHaveTextContent ( 'Three' ) ;
1521
+
1522
+ act ( ( ) => jest . advanceTimersByTime ( 500 ) ) ;
1523
+ act ( ( ) => picker . focus ( ) ) ;
1524
+ act ( ( ) => { fireEvent . keyDown ( picker , { key : 'ArrowDown' } ) ; } ) ;
1525
+ act ( ( ) => jest . runAllTimers ( ) ) ;
1526
+ listbox = getByRole ( 'listbox' ) ;
1527
+ items = within ( listbox ) . getAllByRole ( 'option' ) ;
1528
+ expect ( document . activeElement ) . toBe ( items [ 2 ] ) ;
1529
+ act ( ( ) => { fireEvent . keyDown ( listbox , { key : 'n' } ) ; } ) ;
1530
+ act ( ( ) => { fireEvent . keyDown ( document . activeElement , { key : 'Enter' } ) ; } ) ;
1531
+ act ( ( ) => { fireEvent . keyUp ( document . activeElement , { key : 'Enter' } ) ; } ) ;
1532
+ act ( ( ) => jest . runAllTimers ( ) ) ;
1533
+ expect ( listbox ) . not . toBeInTheDocument ( ) ;
1534
+ expect ( picker ) . toHaveTextContent ( 'None' ) ;
1535
+ expect ( onSelectionChange ) . toHaveBeenCalledTimes ( 2 ) ;
1536
+ expect ( onSelectionChange ) . toHaveBeenLastCalledWith ( '' ) ;
1520
1537
} ) ;
1521
1538
1522
1539
it ( 'does not deselect when pressing an already selected item' , function ( ) {
0 commit comments