@@ -751,7 +751,7 @@ describe('ngOptions', function() {
751
751
} ) ;
752
752
753
753
754
- it ( 'should not select disabled options when model changes' , function ( ) {
754
+ it ( 'should select disabled options when model changes' , function ( ) {
755
755
scope . options = [
756
756
{ name : 'white' , value : '#FFFFFF' } ,
757
757
{ name : 'one' , value : 1 , unavailable : true } ,
@@ -772,11 +772,12 @@ describe('ngOptions', function() {
772
772
scope . $apply ( 'selected = 1' ) ;
773
773
options = element . find ( 'option' ) ;
774
774
775
- expect ( element . val ( ) ) . toEqualUnknownValue ( '?' ) ;
776
- expect ( options . length ) . toEqual ( 5 ) ;
777
- expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
775
+ expect ( element . val ( ) ) . toBe ( 'number:1' ) ;
776
+ expect ( options . length ) . toEqual ( 4 ) ;
777
+ expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
778
+ expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
778
779
expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
779
- expect ( options . eq ( 4 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
780
+ expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
780
781
} ) ;
781
782
782
783
@@ -796,11 +797,12 @@ describe('ngOptions', function() {
796
797
scope . $apply ( 'selected = 1' ) ;
797
798
var options = element . find ( 'option' ) ;
798
799
799
- expect ( element . val ( ) ) . toEqualUnknownValue ( '?' ) ;
800
- expect ( options . length ) . toEqual ( 5 ) ;
801
- expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
800
+ expect ( element . val ( ) ) . toBe ( 'number:1' ) ;
801
+ expect ( options . length ) . toEqual ( 4 ) ;
802
+ expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
803
+ expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
802
804
expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
803
- expect ( options . eq ( 4 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
805
+ expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
804
806
805
807
// Now enable that option
806
808
scope . $apply ( function ( ) {
@@ -841,7 +843,7 @@ describe('ngOptions', function() {
841
843
} ) ;
842
844
843
845
844
- it ( 'should not select disabled options when model changes' , function ( ) {
846
+ it ( 'should select disabled options when model changes' , function ( ) {
845
847
scope . options = [
846
848
{ name : 'a' , value : 0 } ,
847
849
{ name : 'b' , value : 1 , unavailable : true } ,
@@ -866,14 +868,14 @@ describe('ngOptions', function() {
866
868
scope . $apply ( 'selected = [1,3]' ) ;
867
869
options = element . find ( 'option' ) ;
868
870
expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
869
- expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
871
+ expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
870
872
expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
871
873
expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
872
874
873
875
// Now only select the disabled option
874
876
scope . $apply ( 'selected = [1]' ) ;
875
877
expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
876
- expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
878
+ expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
877
879
expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
878
880
expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
879
881
} ) ;
@@ -897,7 +899,7 @@ describe('ngOptions', function() {
897
899
var options = element . find ( 'option' ) ;
898
900
899
901
expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
900
- expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
902
+ expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
901
903
expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
902
904
expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
903
905
@@ -2515,37 +2517,6 @@ describe('ngOptions', function() {
2515
2517
expect ( element . find ( 'option' ) [ 1 ] . selected ) . toBeTruthy ( ) ;
2516
2518
} ) ;
2517
2519
2518
- it ( 'should not write disabled selections from model' , function ( ) {
2519
- scope . selected = [ 30 ] ;
2520
- scope . options = [
2521
- { name : 'white' , value : '#FFFFFF' } ,
2522
- { name : 'one' , value : 1 , unavailable : true } ,
2523
- { name : 'notTrue' , value : false } ,
2524
- { name : 'thirty' , value : 30 , unavailable : false }
2525
- ] ;
2526
- createSelect ( {
2527
- 'ng-options' : 'o.value as o.name disable when o.unavailable for o in options' ,
2528
- 'ng-model' : 'selected' ,
2529
- 'multiple' : true
2530
- } ) ;
2531
-
2532
- var options = element . find ( 'option' ) ;
2533
-
2534
- expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2535
- expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2536
- expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2537
- expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
2538
-
2539
- scope . $apply ( function ( ) {
2540
- scope . selected . push ( 1 ) ;
2541
- } ) ;
2542
-
2543
- expect ( options . eq ( 0 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2544
- expect ( options . eq ( 1 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2545
- expect ( options . eq ( 2 ) . prop ( 'selected' ) ) . toEqual ( false ) ;
2546
- expect ( options . eq ( 3 ) . prop ( 'selected' ) ) . toEqual ( true ) ;
2547
- } ) ;
2548
-
2549
2520
2550
2521
it ( 'should update model on change' , function ( ) {
2551
2522
createMultiSelect ( ) ;
0 commit comments