@@ -827,55 +827,68 @@ describe('Select.Basic', () => {
827
827
expect ( focusSpy ) . toHaveBeenCalled ( ) ;
828
828
} ) ;
829
829
830
- it ( 'combobox could customize input element' , ( ) => {
831
- const onKeyDown = jest . fn ( ) ;
832
- const onChange = jest . fn ( ) ;
833
- const onMouseDown = jest . fn ( ) ;
834
- const onCompositionStart = jest . fn ( ) ;
835
- const onCompositionEnd = jest . fn ( ) ;
836
- const textareaRef = jest . fn ( ) ;
837
- const mouseDownPreventDefault = jest . fn ( ) ;
838
- const wrapper = mount (
839
- < Select
840
- mode = "combobox"
841
- getInputElement = { ( ) => (
842
- < textarea
843
- onKeyDown = { onKeyDown }
844
- onChange = { onChange }
845
- onMouseDown = { onMouseDown }
846
- onCompositionStart = { onCompositionStart }
847
- onCompositionEnd = { onCompositionEnd }
848
- ref = { textareaRef }
849
- className = "custom-input"
850
- />
851
- ) }
852
- >
853
- < Option value = "1" > 1</ Option >
854
- < Option value = "2" > 2</ Option >
855
- </ Select > ,
856
- ) ;
830
+ describe ( 'combobox could customize input element' , ( ) => {
831
+ it ( 'work' , ( ) => {
832
+ const onKeyDown = jest . fn ( ) ;
833
+ const onChange = jest . fn ( ) ;
834
+ const onMouseDown = jest . fn ( ) ;
835
+ const onCompositionStart = jest . fn ( ) ;
836
+ const onCompositionEnd = jest . fn ( ) ;
837
+ const textareaRef = jest . fn ( ) ;
838
+ const mouseDownPreventDefault = jest . fn ( ) ;
839
+ const wrapper = mount (
840
+ < Select
841
+ mode = "combobox"
842
+ getInputElement = { ( ) => (
843
+ < textarea
844
+ onKeyDown = { onKeyDown }
845
+ onChange = { onChange }
846
+ onMouseDown = { onMouseDown }
847
+ onCompositionStart = { onCompositionStart }
848
+ onCompositionEnd = { onCompositionEnd }
849
+ ref = { textareaRef }
850
+ className = "custom-input"
851
+ />
852
+ ) }
853
+ >
854
+ < Option value = "1" > 1</ Option >
855
+ < Option value = "2" > 2</ Option >
856
+ </ Select > ,
857
+ ) ;
857
858
858
- expect ( wrapper . find ( 'textarea' ) . length ) . toBe ( 1 ) ;
859
- toggleOpen ( wrapper ) ;
860
- wrapper
861
- . find ( '.rc-select' )
862
- . find ( 'textarea' )
863
- . simulate ( 'mouseDown' , { preventDefault : mouseDownPreventDefault } )
864
- . simulate ( 'keyDown' , { which : KeyCode . NUM_ONE } )
865
- . simulate ( 'change' , { target : { value : '1' } } )
866
- . simulate ( 'compositionStart' )
867
- . simulate ( 'compositionEnd' ) ;
859
+ expect ( wrapper . find ( 'textarea' ) . length ) . toBe ( 1 ) ;
860
+ toggleOpen ( wrapper ) ;
861
+ wrapper
862
+ . find ( '.rc-select' )
863
+ . find ( 'textarea' )
864
+ . simulate ( 'mouseDown' , { preventDefault : mouseDownPreventDefault } )
865
+ . simulate ( 'keyDown' , { which : KeyCode . NUM_ONE } )
866
+ . simulate ( 'change' , { target : { value : '1' } } )
867
+ . simulate ( 'compositionStart' )
868
+ . simulate ( 'compositionEnd' ) ;
868
869
869
- selectItem ( wrapper ) ;
870
- expect ( wrapper . find ( 'textarea' ) . props ( ) . value ) . toEqual ( '1' ) ;
871
- expect ( wrapper . find ( 'textarea' ) . hasClass ( 'custom-input' ) ) . toBe ( true ) ;
872
- expect ( mouseDownPreventDefault ) . not . toHaveBeenCalled ( ) ;
873
- expect ( onKeyDown ) . toHaveBeenCalled ( ) ;
874
- expect ( onChange ) . toHaveBeenCalled ( ) ;
875
- expect ( onMouseDown ) . toHaveBeenCalled ( ) ;
876
- expect ( textareaRef ) . toHaveBeenCalled ( ) ;
877
- expect ( onCompositionStart ) . toHaveBeenCalled ( ) ;
878
- expect ( onCompositionEnd ) . toHaveBeenCalled ( ) ;
870
+ selectItem ( wrapper ) ;
871
+ expect ( wrapper . find ( 'textarea' ) . props ( ) . value ) . toEqual ( '1' ) ;
872
+ expect ( wrapper . find ( 'textarea' ) . hasClass ( 'custom-input' ) ) . toBe ( true ) ;
873
+ expect ( mouseDownPreventDefault ) . not . toHaveBeenCalled ( ) ;
874
+ expect ( onKeyDown ) . toHaveBeenCalled ( ) ;
875
+ expect ( onChange ) . toHaveBeenCalled ( ) ;
876
+ expect ( onMouseDown ) . toHaveBeenCalled ( ) ;
877
+ expect ( textareaRef ) . toHaveBeenCalled ( ) ;
878
+ expect ( onCompositionStart ) . toHaveBeenCalled ( ) ;
879
+ expect ( onCompositionEnd ) . toHaveBeenCalled ( ) ;
880
+ } ) ;
881
+
882
+ it ( 'not override customize props' , ( ) => {
883
+ const wrapper = mount (
884
+ < Select mode = "combobox" getInputElement = { ( ) => < input type = "email" /> } >
885
+ < Option value = "1" > 1</ Option >
886
+ < Option value = "2" > 2</ Option >
887
+ </ Select > ,
888
+ ) ;
889
+
890
+ expect ( wrapper . find ( 'input' ) . prop ( 'type' ) ) . toEqual ( 'email' ) ;
891
+ } ) ;
879
892
} ) ;
880
893
881
894
it ( 'getRawInputElement for rc-cascader' , ( ) => {
@@ -1370,7 +1383,6 @@ describe('Select.Basic', () => {
1370
1383
) ;
1371
1384
1372
1385
for ( let i = 0 ; i < 10 ; i += 1 ) {
1373
- console . log ( '=>' , i ) ;
1374
1386
onSelect . mockReset ( ) ;
1375
1387
wrapper . find ( 'input' ) . simulate ( 'keyDown' , { which : KeyCode . ENTER } ) ;
1376
1388
expect ( onSelect ) . toHaveBeenCalledWith ( '1' , expect . anything ( ) ) ;
0 commit comments