@@ -743,6 +743,7 @@ describe('ngOptions', function() {
743
743
expect ( options . eq ( 3 ) ) . toEqualOption ( 'c' ) ;
744
744
} ) ;
745
745
746
+
746
747
it ( 'should remove the "selected" attribute from the previous option when the model changes' , function ( ) {
747
748
scope . values = [ { id : 10 , label : 'ten' } , { id :20 , label : 'twenty' } ] ;
748
749
@@ -751,18 +752,22 @@ describe('ngOptions', function() {
751
752
'ng-options' : 'item.label for item in values'
752
753
} , true ) ;
753
754
754
- var resetButton = angular . element ( '<input type="reset" />' ) ;
755
- formElement . append ( resetButton ) ;
755
+ var options = element . find ( 'option' ) ;
756
+ expect ( options [ 0 ] . getAttribute ( 'selected' ) ) . toBe ( 'selected' ) ;
757
+ expect ( options [ 1 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
758
+ expect ( options [ 2 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
756
759
757
760
scope . selected = scope . values [ 0 ] ;
758
761
scope . $digest ( ) ;
759
762
760
- var options = element . find ( 'option' ) ;
763
+ expect ( options [ 0 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
761
764
expect ( options [ 1 ] . getAttribute ( 'selected' ) ) . toBe ( 'selected' ) ;
765
+ expect ( options [ 2 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
762
766
763
767
scope . selected = scope . values [ 1 ] ;
764
768
scope . $digest ( ) ;
765
769
770
+ expect ( options [ 0 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
766
771
expect ( options [ 1 ] . hasAttribute ( 'selected' ) ) . toBe ( false ) ;
767
772
expect ( options [ 2 ] . getAttribute ( 'selected' ) ) . toBe ( 'selected' ) ;
768
773
@@ -1441,7 +1446,6 @@ describe('ngOptions', function() {
1441
1446
scope . selected = { } ;
1442
1447
scope . $digest ( ) ;
1443
1448
1444
- options [ 2 ] . selected = false ;
1445
1449
expect ( options [ 0 ] . selected ) . toBe ( true ) ;
1446
1450
expect ( options [ 0 ] . getAttribute ( 'selected' ) ) . toBe ( 'selected' ) ;
1447
1451
expect ( options [ 2 ] . selected ) . toBe ( false ) ;
0 commit comments