@@ -843,28 +843,54 @@ describe('ngRepeat', function() {
843
843
} ) ;
844
844
} ) ;
845
845
846
- it ( 'should grow multi-node repeater' , inject ( function ( $compile , $rootScope ) {
847
- $rootScope . show = false ;
848
- $rootScope . books = [
849
- { title :'T1' , description : 'D1' } ,
850
- { title :'T2' , description : 'D2' }
851
- ] ;
852
- element = $compile (
846
+
847
+ describe ( 'ngRepeatStart' , function ( ) {
848
+ it ( 'should grow multi-node repeater' , inject ( function ( $compile , $rootScope ) {
849
+ $rootScope . show = false ;
850
+ $rootScope . books = [
851
+ { title :'T1' , description : 'D1' } ,
852
+ { title :'T2' , description : 'D2' }
853
+ ] ;
854
+ element = $compile (
855
+ '<div>' +
856
+ '<dt ng-repeat-start="book in books">{{book.title}}:</dt>' +
857
+ '<dd ng-repeat-end>{{book.description}};</dd>' +
858
+ '</div>' ) ( $rootScope ) ;
859
+
860
+ $rootScope . $digest ( ) ;
861
+ expect ( element . text ( ) ) . toEqual ( 'T1:D1;T2:D2;' ) ;
862
+ $rootScope . books . push ( { title :'T3' , description : 'D3' } ) ;
863
+ $rootScope . $digest ( ) ;
864
+ expect ( element . text ( ) ) . toEqual ( 'T1:D1;T2:D2;T3:D3;' ) ;
865
+ } ) ) ;
866
+
867
+
868
+ iit ( 'should not clobber ng-if when updating collection' , inject ( function ( $compile , $rootScope ) {
869
+ $rootScope . values = [ 1 , 2 , 3 ] ;
870
+ $rootScope . showMe = true ;
871
+
872
+ element = $compile (
853
873
'<div>' +
854
- '<dt ng-repeat-start="book in books">{{book.title}}:</dt>' +
855
- '<dd ng-repeat-end>{{book.description}};</dd>' +
856
- '</div>' ) ( $rootScope ) ;
874
+ '<div ng-repeat-start="val in values">Value: {{val}} </div>' +
875
+ '<div ng-if="showMe" ng-repeat-end>If : {{val}}</div>' +
876
+ '</div>'
877
+ ) ( $rootScope ) ;
857
878
858
- $rootScope . $digest ( ) ;
859
- expect ( element . text ( ) ) . toEqual ( 'T1:D1;T2:D2;' ) ;
860
- $rootScope . books . push ( { title :'T3' , description : 'D3' } ) ;
861
- $rootScope . $digest ( ) ;
862
- expect ( element . text ( ) ) . toEqual ( 'T1:D1;T2:D2;T3:D3;' ) ;
863
- } ) ) ;
879
+ $rootScope . $digest ( ) ;
880
+ expect ( element . find ( 'div' ) . length ) . toBe ( 6 ) ;
864
881
882
+ $rootScope . values . shift ( ) ;
883
+ $rootScope . values . push ( 5 ) ;
865
884
885
+ $rootScope . $digest ( ) ;
886
+ dump ( element ) ;
887
+ expect ( element . find ( 'div' ) . length ) . toBe ( 6 ) ;
888
+ expect ( element . text ( ) ) . not . toContain ( 'If : 1' ) ;
889
+ } ) ) ;
890
+ } ) ;
866
891
} ) ;
867
892
893
+
868
894
describe ( 'ngRepeat animations' , function ( ) {
869
895
var body , element , $rootElement ;
870
896
@@ -982,5 +1008,4 @@ describe('ngRepeat animations', function() {
982
1008
item = $animate . flushNext ( 'move' ) . element ;
983
1009
expect ( item . text ( ) ) . toBe ( '1' ) ;
984
1010
} ) ) ;
985
-
986
1011
} ) ;
0 commit comments