@@ -63,7 +63,7 @@ describe('$validate', () => {
63
63
assert ( vm . $validator1 . dirty === true )
64
64
assert ( vm . $validator1 . modified === true )
65
65
assert ( vm . $validator1 . touched === false )
66
-
66
+
67
67
done ( )
68
68
} )
69
69
} )
@@ -254,6 +254,22 @@ describe('$validate', () => {
254
254
+ '<form novalidate>'
255
255
+ '<input type="number" v-validate:field1="{ required: true, min: 0, max: 10 }">'
256
256
+ '<input type="text" value="hello" v-validate:field2="{ minlength: 4 }">'
257
+ + '<input type="checkbox" value="foo" v-validate:checkbox="{ required: true, minlength: 1 }">'
258
+ + '<input type="checkbox" value="bar" v-validate:checkbox>'
259
+ + '<input type="checkbox" value="buz" v-validate:checkbox>'
260
+ + '<fieldset>'
261
+ + '<label for="radio1">radio1</label>'
262
+ + '<input type="radio" id="radio1" name="r1" checked value="foo" v-validate:radio="{ required: true }">'
263
+ + '<label for="radio2">radio2</label>'
264
+ + '<input type="radio" id="radio2" name="r1" value="bar" v-validate:radio="{ required: true }">'
265
+ + '</fieldset>'
266
+ + '<select multiple v-validate:select="{ required: true, minlength: 2 }">'
267
+ + '<option value="en">english</option>'
268
+ + '<option value="ja">japanese</option>'
269
+ + '<option value="zh">chinese</option>'
270
+ + '<option value="fr">french</option>'
271
+ + '<option value="de">German</option>'
272
+ + '</select>'
257
273
+ '</form>'
258
274
+ '</validator>'
259
275
vm = new Vue ( { el : el } )
@@ -353,5 +369,44 @@ describe('$validate', () => {
353
369
} )
354
370
} )
355
371
} )
372
+
373
+ describe ( 'touched for all validatable elements' , ( ) => {
374
+ it ( 'should be validated' , ( done ) => {
375
+ assert ( vm . $validator1 . field1 . touched === false )
376
+ assert ( vm . $validator1 . field2 . touched === false )
377
+ assert ( vm . $validator1 . checkbox . touched === false )
378
+ assert ( vm . $validator1 . radio . touched === false )
379
+ assert ( vm . $validator1 . select . touched === false )
380
+ assert ( vm . $validator1 . touched === false )
381
+
382
+ vm . $nextTick ( ( ) => {
383
+ vm . $validate ( 'field2' )
384
+ vm . $validate ( 'checkbox' )
385
+ vm . $validate ( 'radio' )
386
+ vm . $validate ( 'select' )
387
+
388
+ assert ( vm . $validator1 . field1 . touched === false )
389
+ assert ( vm . $validator1 . field2 . touched === false )
390
+ assert ( vm . $validator1 . checkbox . touched === false )
391
+ assert ( vm . $validator1 . radio . touched === false )
392
+ assert ( vm . $validator1 . select . touched === false )
393
+ assert ( vm . $validator1 . touched === false )
394
+
395
+ vm . $validate ( 'field2' , true )
396
+ vm . $validate ( 'checkbox' , true )
397
+ vm . $validate ( 'radio' , true )
398
+ vm . $validate ( 'select' , true )
399
+
400
+ assert ( vm . $validator1 . field1 . touched === false )
401
+ assert ( vm . $validator1 . field2 . touched === true )
402
+ assert ( vm . $validator1 . checkbox . touched === true )
403
+ assert ( vm . $validator1 . radio . touched === true )
404
+ assert ( vm . $validator1 . select . touched === true )
405
+ assert ( vm . $validator1 . touched === true )
406
+
407
+ done ( )
408
+ } )
409
+ } )
410
+ } )
356
411
} )
357
412
} )
0 commit comments