@@ -73,7 +73,7 @@ describe('Select.Tags', () => {
73
73
</ Select > ,
74
74
) ;
75
75
76
- wrapper . find ( 'input' ) . instance ( ) . focus = jest . fn ( ) ;
76
+ ( wrapper . find ( 'input' ) . instance ( ) as any ) . focus = jest . fn ( ) ;
77
77
78
78
wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '2,3,4' } } ) ;
79
79
@@ -87,6 +87,34 @@ describe('Select.Tags', () => {
87
87
expectOpen ( wrapper , false ) ;
88
88
} ) ;
89
89
90
+ it ( "shounld't separate words when compositing" , ( ) => {
91
+ const handleChange = jest . fn ( ) ;
92
+ const handleSelect = jest . fn ( ) ;
93
+ const option2 = < Option value = "2" > 2</ Option > ;
94
+ const wrapper = mount (
95
+ < Select mode = "tags" tokenSeparators = { [ ',' ] } onChange = { handleChange } onSelect = { handleSelect } >
96
+ < Option value = "1" > 1</ Option >
97
+ { option2 }
98
+ </ Select > ,
99
+ ) ;
100
+
101
+ ( wrapper . find ( 'input' ) . instance ( ) as any ) . focus = jest . fn ( ) ;
102
+ wrapper . find ( 'input' ) . simulate ( 'compositionstart' ) ;
103
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '2,3,4' } } ) ;
104
+ expect ( handleChange ) . not . toHaveBeenCalled ( ) ;
105
+ handleChange . mockReset ( ) ;
106
+ wrapper . find ( 'input' ) . simulate ( 'compositionend' ) ;
107
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '2,3,4' } } ) ;
108
+ expect ( handleChange ) . toHaveBeenCalledWith ( [ '2' , '3' , '4' ] , expect . anything ( ) ) ;
109
+ expect ( handleSelect ) . toHaveBeenCalledTimes ( 3 ) ;
110
+ expect ( handleSelect ) . toHaveBeenLastCalledWith ( '4' , expect . anything ( ) ) ;
111
+ expect ( findSelection ( wrapper ) . text ( ) ) . toEqual ( '2' ) ;
112
+ expect ( findSelection ( wrapper , 1 ) . text ( ) ) . toEqual ( '3' ) ;
113
+ expect ( findSelection ( wrapper , 2 ) . text ( ) ) . toEqual ( '4' ) ;
114
+ expect ( wrapper . find ( 'input' ) . props ( ) . value ) . toBe ( '' ) ;
115
+ expectOpen ( wrapper , false ) ;
116
+ } ) ;
117
+
90
118
it ( 'paste content to split' , ( ) => {
91
119
const onChange = jest . fn ( ) ;
92
120
const wrapper = mount (
@@ -193,7 +221,7 @@ describe('Select.Tags', () => {
193
221
} ;
194
222
const wrapper = mount ( < Select mode = "tags" tokenSeparators = { [ ',' ] } tagRender = { tagRender } /> ) ;
195
223
196
- wrapper . find ( 'input' ) . instance ( ) . focus = jest . fn ( ) ;
224
+ ( wrapper . find ( 'input' ) . instance ( ) as any ) . focus = jest . fn ( ) ;
197
225
198
226
wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : '1,A,42' } } ) ;
199
227
0 commit comments