File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,50 @@ if (_.inBrowser) {
221
221
} )
222
222
} )
223
223
224
+ it ( 'checkbox + array model' , function ( done ) {
225
+ var vm = new Vue ( {
226
+ el : el ,
227
+ data : {
228
+ list : [ 1 ] ,
229
+ a : { }
230
+ } ,
231
+ template :
232
+ '<input type="checkbox" v-model="list" number value="1">' +
233
+ '<input type="checkbox" v-model="list" :value="a">'
234
+ } )
235
+ expect ( el . firstChild . checked ) . toBe ( true )
236
+ expect ( el . lastChild . checked ) . toBe ( false )
237
+ el . firstChild . click ( )
238
+ expect ( vm . list . length ) . toBe ( 0 )
239
+ el . lastChild . click ( )
240
+ expect ( vm . list . length ) . toBe ( 1 )
241
+ expect ( vm . list [ 0 ] ) . toBe ( vm . a )
242
+ el . firstChild . click ( )
243
+ expect ( vm . list . length ) . toBe ( 2 )
244
+ expect ( vm . list [ 1 ] ) . toBe ( 1 )
245
+ vm . list = [ vm . a ]
246
+ _ . nextTick ( function ( ) {
247
+ expect ( el . firstChild . checked ) . toBe ( false )
248
+ expect ( el . lastChild . checked ) . toBe ( true )
249
+ done ( )
250
+ } )
251
+ } )
252
+
253
+ it ( 'checkbox + array model default value' , function ( ) {
254
+ var vm = new Vue ( {
255
+ el : el ,
256
+ data : {
257
+ list : [ ] ,
258
+ a : { }
259
+ } ,
260
+ template :
261
+ '<input type="checkbox" v-model="list" number value="1">' +
262
+ '<input type="checkbox" checked v-model="list" :value="a">'
263
+ } )
264
+ expect ( vm . list . length ) . toBe ( 1 )
265
+ expect ( vm . list [ 0 ] ) . toBe ( vm . a )
266
+ } )
267
+
224
268
it ( 'select' , function ( done ) {
225
269
var vm = new Vue ( {
226
270
el : el ,
You can’t perform that action at this time.
0 commit comments