File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -230,4 +230,41 @@ describe('Radio', () => {
230
230
} ) ;
231
231
expect ( wrapper . html ( ) ) . toMatchSnapshot ( ) ;
232
232
} ) ;
233
+
234
+ it ( 'when onChange do not change the value, change event can be also triggered.' , async ( ) => {
235
+ const onChange = jest . fn ( ) ;
236
+ const onChangeRadioGroup = ( ) => {
237
+ onChange ( ) ;
238
+ wrapper . setProps ( { value : 'A' } ) ;
239
+ } ;
240
+
241
+ const wrapper = mount (
242
+ {
243
+ props : [ 'value' ] ,
244
+ render ( ) {
245
+ const value = this . value || 'A' ;
246
+ return (
247
+ < RadioGroup ref = "radioGroup" value = { value } onChange = { onChangeRadioGroup } >
248
+ < Radio value = "A" > A</ Radio >
249
+ < Radio value = "B" > B</ Radio >
250
+ < Radio value = "C" > C</ Radio >
251
+ </ RadioGroup >
252
+ ) ;
253
+ } ,
254
+ } ,
255
+ { sync : false } ,
256
+ ) ;
257
+
258
+ const radios = wrapper . findAll ( 'input' ) ;
259
+
260
+ await asyncExpect ( ( ) => {
261
+ radios . at ( 1 ) . trigger ( 'click' ) ;
262
+ expect ( onChange . mock . calls . length ) . toBe ( 1 ) ;
263
+ } ) ;
264
+
265
+ await asyncExpect ( ( ) => {
266
+ radios . at ( 1 ) . trigger ( 'click' ) ;
267
+ expect ( onChange . mock . calls . length ) . toBe ( 2 ) ;
268
+ } ) ;
269
+ } ) ;
233
270
} ) ;
Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ export default {
92
92
nativeEvent : e ,
93
93
} ) ;
94
94
this . eventShiftKey = false ;
95
+ // fix https://github.com/vueComponent/ant-design-vue/issues/3047
96
+ if ( 'checked' in props ) {
97
+ this . $refs . input . checked = props . checked ;
98
+ }
95
99
} ,
96
100
onClick ( e ) {
97
101
this . __emit ( 'click' , e ) ;
You can’t perform that action at this time.
0 commit comments