@@ -463,7 +463,7 @@ describe('form', function() {
463
463
doc = jqLite (
464
464
'<form name="parent">' +
465
465
'<div class="ng-form" name="child">' +
466
- '<input ng-if="inputPresent" ng-model="modelA" name="inputA" required>' +
466
+ '<input ng-if="inputPresent" ng-model="modelA" name="inputA" required maxlength="10" >' +
467
467
'</div>' +
468
468
'</form>' ) ;
469
469
$compile ( doc ) ( scope ) ;
@@ -476,23 +476,40 @@ describe('form', function() {
476
476
477
477
expect ( parent ) . toBeDefined ( ) ;
478
478
expect ( child ) . toBeDefined ( ) ;
479
+
479
480
expect ( parent . $error . required ) . toEqual ( [ child ] ) ;
481
+ expect ( parent . $$success . maxlength ) . toEqual ( [ child ] ) ;
482
+
480
483
expect ( child . $error . required ) . toEqual ( [ input ] ) ;
484
+ expect ( child . $$success . maxlength ) . toEqual ( [ input ] ) ;
485
+
481
486
expect ( doc . hasClass ( 'ng-invalid' ) ) . toBe ( true ) ;
482
487
expect ( doc . hasClass ( 'ng-invalid-required' ) ) . toBe ( true ) ;
488
+ expect ( doc . hasClass ( 'ng-valid-maxlength' ) ) . toBe ( true ) ;
483
489
expect ( doc . find ( 'div' ) . hasClass ( 'ng-invalid' ) ) . toBe ( true ) ;
484
490
expect ( doc . find ( 'div' ) . hasClass ( 'ng-invalid-required' ) ) . toBe ( true ) ;
491
+ expect ( doc . find ( 'div' ) . hasClass ( 'ng-valid-maxlength' ) ) . toBe ( true ) ;
485
492
486
493
//remove child input
487
- scope . inputPresent = false ;
488
- scope . $apply ( ) ;
494
+ scope . $apply ( 'inputPresent = false' ) ;
489
495
490
496
expect ( parent . $error . required ) . toBeFalsy ( ) ;
497
+ expect ( parent . $$success . maxlength ) . toBeFalsy ( ) ;
498
+
491
499
expect ( child . $error . required ) . toBeFalsy ( ) ;
500
+ expect ( child . $$success . maxlength ) . toBeFalsy ( ) ;
501
+
492
502
expect ( doc . hasClass ( 'ng-valid' ) ) . toBe ( true ) ;
493
503
expect ( doc . hasClass ( 'ng-valid-required' ) ) . toBe ( false ) ;
504
+ expect ( doc . hasClass ( 'ng-invalid-required' ) ) . toBe ( false ) ;
505
+ expect ( doc . hasClass ( 'ng-valid-maxlength' ) ) . toBe ( false ) ;
506
+ expect ( doc . hasClass ( 'ng-invalid-maxlength' ) ) . toBe ( false ) ;
507
+
494
508
expect ( doc . find ( 'div' ) . hasClass ( 'ng-valid' ) ) . toBe ( true ) ;
495
509
expect ( doc . find ( 'div' ) . hasClass ( 'ng-valid-required' ) ) . toBe ( false ) ;
510
+ expect ( doc . find ( 'div' ) . hasClass ( 'ng-invalid-required' ) ) . toBe ( false ) ;
511
+ expect ( doc . find ( 'div' ) . hasClass ( 'ng-valid-maxlength' ) ) . toBe ( false ) ;
512
+ expect ( doc . find ( 'div' ) . hasClass ( 'ng-invalid-maxlength' ) ) . toBe ( false ) ;
496
513
} ) ;
497
514
498
515
it ( 'should leave the parent form invalid when deregister a removed input' , function ( ) {
0 commit comments