@@ -1491,39 +1491,44 @@ test('should not call onChange on hitting backspace even when backspaceRemovesVa
1491
1491
expect ( onChangeSpy ) . not . toHaveBeenCalled ( ) ;
1492
1492
} ) ;
1493
1493
1494
- test ( 'should call onChange with `null` on hitting backspace when backspaceRemovesValue is true and isMulti is false' , ( ) => {
1494
+ cases ( 'should call onChange with `null` on hitting backspace when backspaceRemovesValue is true' , ( { props = { ... BASIC_PROPS } , expectedValue } ) => {
1495
1495
let onChangeSpy = jest . fn ( ) ;
1496
1496
let selectWrapper = mount (
1497
1497
< Select
1498
- { ...BASIC_PROPS }
1498
+ { ...props }
1499
1499
backspaceRemovesValue
1500
1500
isClearable
1501
- isMulti = { false }
1502
1501
onChange = { onChangeSpy }
1503
1502
/>
1504
1503
) ;
1505
1504
selectWrapper
1506
1505
. find ( Control )
1507
1506
. simulate ( 'keyDown' , { keyCode : 8 , key : 'Backspace' } ) ;
1508
- expect ( onChangeSpy ) . toHaveBeenCalledWith ( null , { action : 'clear' , name : 'test-input-name' } ) ;
1507
+ expect ( onChangeSpy ) . toHaveBeenCalledWith ( null , expectedValue ) ;
1508
+ } , {
1509
+ 'and isMulti is false' : {
1510
+ props : {
1511
+ ...BASIC_PROPS ,
1512
+ isMulti : false ,
1513
+ } ,
1514
+ expectedValue : {
1515
+ action : 'clear' ,
1516
+ name : 'test-input-name' ,
1517
+ }
1518
+ } ,
1519
+ 'and isMulti is true' : {
1520
+ props : {
1521
+ ...BASIC_PROPS ,
1522
+ isMulti : true ,
1523
+ } ,
1524
+ expectedValue : {
1525
+ action : 'pop-value' ,
1526
+ name : 'test-input-name' ,
1527
+ removedValue : undefined
1528
+ }
1529
+ } ,
1509
1530
} ) ;
1510
1531
1511
- test ( 'should call onChange with an array on hitting backspace when backspaceRemovesValue is true and isMulti is true' , ( ) => {
1512
- let onChangeSpy = jest . fn ( ) ;
1513
- let selectWrapper = mount (
1514
- < Select
1515
- { ...BASIC_PROPS }
1516
- backspaceRemovesValue
1517
- isClearable
1518
- isMulti
1519
- onChange = { onChangeSpy }
1520
- />
1521
- ) ;
1522
- selectWrapper
1523
- . find ( Control )
1524
- . simulate ( 'keyDown' , { keyCode : 8 , key : 'Backspace' } ) ;
1525
- expect ( onChangeSpy ) . toHaveBeenCalledWith ( [ ] , { action : 'pop-value' , name : 'test-input-name' , removedValue : undefined } ) ;
1526
- } ) ;
1527
1532
1528
1533
test ( 'multi select > clicking on X next to option will call onChange with all options other that the clicked option' , ( ) => {
1529
1534
let onChangeSpy = jest . fn ( ) ;
0 commit comments