@@ -57,22 +57,22 @@ describeWithShallowAndMount('setChecked', mountingMethod => {
57
57
58
58
it ( 'should trigger a change event when called on a checkbox' , ( ) => {
59
59
const listeners = { change : sinon . spy ( ) }
60
- const input = mountingMethod ( {
61
- template : `<input type="checkbox" v-on="$listeners">` ,
62
- } , { listeners } )
63
60
64
- input . setChecked ( )
61
+ mountingMethod (
62
+ { template : `<input type="checkbox" v-on="$listeners">` } ,
63
+ { listeners } ,
64
+ ) . setChecked ( )
65
65
66
66
expect ( listeners . change ) . to . have . been . called
67
67
} ) ;
68
68
69
69
it ( 'should not trigger a change event if the checkbox is already checked' , ( ) => {
70
70
const listeners = { change : sinon . spy ( ) }
71
- const input = mountingMethod ( {
72
- template : `<input type="checkbox" checked v-on="$listeners">` ,
73
- } , { listeners } )
74
71
75
- input . setChecked ( )
72
+ mountingMethod (
73
+ { template : `<input type="checkbox" checked v-on="$listeners">` } ,
74
+ { listeners } ,
75
+ ) . setChecked ( )
76
76
77
77
expect ( listeners . change ) . not . to . have . been . called
78
78
} ) ;
@@ -111,6 +111,28 @@ describeWithShallowAndMount('setChecked', mountingMethod => {
111
111
expect ( wrapper . find ( '.counter' ) . text ( ) ) . to . equal ( '4' )
112
112
} )
113
113
114
+ it ( 'should trigger a change event when called on a radio button' , ( ) => {
115
+ const listeners = { change : sinon . spy ( ) }
116
+
117
+ mountingMethod (
118
+ { template : `<input type="radio" v-on="$listeners">` } ,
119
+ { listeners } ,
120
+ ) . setChecked ( )
121
+
122
+ expect ( listeners . change ) . to . have . been . called
123
+ } ) ;
124
+
125
+ it ( 'should not trigger a change event if the radio button is already selected' , ( ) => {
126
+ const listeners = { change : sinon . spy ( ) }
127
+
128
+ mountingMethod (
129
+ { template : `<input type="radio" checked v-on="$listeners">` } ,
130
+ { listeners } ,
131
+ ) . setChecked ( )
132
+
133
+ expect ( listeners . change ) . not . to . have . been . called
134
+ } ) ;
135
+
114
136
it ( 'throws error if checked param is not boolean' , ( ) => {
115
137
const message = 'wrapper.setChecked() must be passed a boolean'
116
138
const wrapper = mountingMethod ( ComponentWithInput )
0 commit comments