File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
test/unit/specs/directives/public Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,50 @@ if (_.inBrowser) {
167
167
} )
168
168
} )
169
169
170
+ it ( 'checkbox + array model' , function ( done ) {
171
+ var vm = new Vue ( {
172
+ el : el ,
173
+ data : {
174
+ list : [ 1 ] ,
175
+ a : { }
176
+ } ,
177
+ template :
178
+ '<input type="checkbox" v-model="list" number value="1">' +
179
+ '<input type="checkbox" v-model="list" :value="a">'
180
+ } )
181
+ expect ( el . firstChild . checked ) . toBe ( true )
182
+ expect ( el . lastChild . checked ) . toBe ( false )
183
+ el . firstChild . click ( )
184
+ expect ( vm . list . length ) . toBe ( 0 )
185
+ el . lastChild . click ( )
186
+ expect ( vm . list . length ) . toBe ( 1 )
187
+ expect ( vm . list [ 0 ] ) . toBe ( vm . a )
188
+ el . firstChild . click ( )
189
+ expect ( vm . list . length ) . toBe ( 2 )
190
+ expect ( vm . list [ 1 ] ) . toBe ( 1 )
191
+ vm . list = [ vm . a ]
192
+ _ . nextTick ( function ( ) {
193
+ expect ( el . firstChild . checked ) . toBe ( false )
194
+ expect ( el . lastChild . checked ) . toBe ( true )
195
+ done ( )
196
+ } )
197
+ } )
198
+
199
+ it ( 'checkbox + array model default value' , function ( ) {
200
+ var vm = new Vue ( {
201
+ el : el ,
202
+ data : {
203
+ list : [ ] ,
204
+ a : { }
205
+ } ,
206
+ template :
207
+ '<input type="checkbox" v-model="list" number value="1">' +
208
+ '<input type="checkbox" checked v-model="list" :value="a">'
209
+ } )
210
+ expect ( vm . list . length ) . toBe ( 1 )
211
+ expect ( vm . list [ 0 ] ) . toBe ( vm . a )
212
+ } )
213
+
170
214
it ( 'select' , function ( done ) {
171
215
var vm = new Vue ( {
172
216
el : el ,
You can’t perform that action at this time.
0 commit comments