@@ -387,6 +387,19 @@ describe('<md-select>', function() {
387
387
expect ( selectedOptions ( el ) . length ) . toBe ( 0 ) ;
388
388
} ) ) ;
389
389
390
+ it ( 'should keep the form pristine when model is predefined' , inject ( function ( $rootScope , $timeout , $compile ) {
391
+ $rootScope . model = 2 ;
392
+ $rootScope . opts = [ 1 , 2 , 3 , 4 ] ;
393
+ $compile ( '<form name="testForm">' +
394
+ '<md-select ng-model="model" name="multiSelect">' +
395
+ '<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
396
+ '</md-select></form>' ) ( $rootScope ) ;
397
+ $rootScope . $digest ( ) ;
398
+ $timeout . flush ( ) ;
399
+
400
+ expect ( $rootScope . testForm . $pristine ) . toBe ( true ) ;
401
+ } ) ) ;
402
+
390
403
} ) ;
391
404
392
405
describe ( 'view->model' , function ( ) {
@@ -637,13 +650,25 @@ describe('<md-select>', function() {
637
650
$rootScope . model = [ ] ;
638
651
$rootScope . opts = [ 1 , 2 , 3 , 4 ] ;
639
652
$compile ( '<form name="testForm">' +
640
- '<md-select ng-model="model", name="multiSelect" required="required" multiple="multiple">' +
653
+ '<md-select ng-model="model" name="multiSelect" required="required" multiple="multiple">' +
641
654
'<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
642
655
'</md-select></form>' ) ( $rootScope ) ;
643
656
$rootScope . $digest ( ) ;
644
657
expect ( $rootScope . testForm . $valid ) . toBe ( false ) ;
645
658
} ) ) ;
646
659
660
+ it ( 'should keep the form pristine when model is predefined' , inject ( function ( $rootScope , $timeout , $compile ) {
661
+ $rootScope . model = [ 1 , 2 ] ;
662
+ $rootScope . opts = [ 1 , 2 , 3 , 4 ] ;
663
+ $compile ( '<form name="testForm">' +
664
+ '<md-select ng-model="model" name="multiSelect" multiple="multiple">' +
665
+ '<md-option ng-repeat="opt in opts" ng-value="opt"></md-option>' +
666
+ '</md-select></form>' ) ( $rootScope ) ;
667
+ $rootScope . $digest ( ) ;
668
+ $timeout . flush ( ) ;
669
+
670
+ expect ( $rootScope . testForm . $pristine ) . toBe ( true ) ;
671
+ } ) ) ;
647
672
} ) ;
648
673
649
674
describe ( 'view->model' , function ( ) {
0 commit comments