@@ -1643,48 +1643,46 @@ test('should not call onChange on hitting backspace even when backspaceRemovesVa
1643
1643
expect ( onChangeSpy ) . not . toHaveBeenCalled ( ) ;
1644
1644
} ) ;
1645
1645
1646
- cases (
1647
- 'should call onChange with `null` on hitting backspace when backspaceRemovesValue is true' ,
1648
- ( { props = { ...BASIC_PROPS } , expectedValue } ) => {
1649
- let onChangeSpy = jest . fn ( ) ;
1650
- let { container } = render (
1651
- < Select
1652
- { ...props }
1653
- backspaceRemovesValue
1654
- isClearable
1655
- onChange = { onChangeSpy }
1656
- />
1657
- ) ;
1658
- fireEvent . keyDown ( container . querySelector ( '.react-select__control' ) , {
1659
- keyCode : 8 ,
1660
- key : 'Backspace' ,
1661
- } ) ;
1662
- expect ( onChangeSpy ) . toHaveBeenCalledWith ( null , expectedValue ) ;
1663
- } ,
1664
- {
1665
- 'and isMulti is false' : {
1666
- props : {
1667
- ...BASIC_PROPS ,
1668
- isMulti : false ,
1669
- } ,
1670
- expectedValue : {
1671
- action : 'clear' ,
1672
- name : 'test-input-name' ,
1673
- } ,
1674
- } ,
1675
- 'and isMulti is true' : {
1676
- props : {
1677
- ...BASIC_PROPS ,
1678
- isMulti : true ,
1679
- } ,
1680
- expectedValue : {
1681
- action : 'pop-value' ,
1682
- name : 'test-input-name' ,
1683
- removedValue : undefined ,
1684
- } ,
1685
- } ,
1686
- }
1687
- ) ;
1646
+ test ( 'should call onChange with `null` on hitting backspace when backspaceRemovesValue is true and isMulti is false' , ( ) => {
1647
+ let onChangeSpy = jest . fn ( ) ;
1648
+ let selectWrapper = mount (
1649
+ < Select
1650
+ { ...BASIC_PROPS }
1651
+ backspaceRemovesValue
1652
+ isClearable
1653
+ isMulti = { false }
1654
+ onChange = { onChangeSpy }
1655
+ />
1656
+ ) ;
1657
+ selectWrapper
1658
+ . find ( Control )
1659
+ . simulate ( 'keyDown' , { keyCode : 8 , key : 'Backspace' } ) ;
1660
+ expect ( onChangeSpy ) . toHaveBeenCalledWith ( null , {
1661
+ action : 'clear' ,
1662
+ name : 'test-input-name' ,
1663
+ } ) ;
1664
+ } ) ;
1665
+
1666
+ test ( 'should call onChange with an array on hitting backspace when backspaceRemovesValue is true and isMulti is true' , ( ) => {
1667
+ let onChangeSpy = jest . fn ( ) ;
1668
+ let selectWrapper = mount (
1669
+ < Select
1670
+ { ...BASIC_PROPS }
1671
+ backspaceRemovesValue
1672
+ isClearable
1673
+ isMulti
1674
+ onChange = { onChangeSpy }
1675
+ />
1676
+ ) ;
1677
+ selectWrapper
1678
+ . find ( Control )
1679
+ . simulate ( 'keyDown' , { keyCode : 8 , key : 'Backspace' } ) ;
1680
+ expect ( onChangeSpy ) . toHaveBeenCalledWith ( [ ] , {
1681
+ action : 'pop-value' ,
1682
+ name : 'test-input-name' ,
1683
+ removedValue : undefined ,
1684
+ } ) ;
1685
+ } ) ;
1688
1686
1689
1687
test ( 'multi select > clicking on X next to option will call onChange with all options other that the clicked option' , ( ) => {
1690
1688
let onChangeSpy = jest . fn ( ) ;
0 commit comments