@@ -35,4 +35,30 @@ describe('chunkByFilter', function() {
3535 it ( 'should get a !collection and return it as-is' , function ( ) {
3636 expect ( filter ( undefined ) ) . toEqual ( undefined ) ;
3737 } ) ;
38+
39+ describe ( 'inside the DOM' , function ( ) {
40+ it ( 'should not throw and not trigger the infinite digest exception' ,
41+ inject ( function ( $rootScope , $compile ) {
42+ var scope = $rootScope . $new ( ) ;
43+ scope . list = [
44+ { name : 'foo' , team : 'a' } ,
45+ { name : 'lol' , team : 'b' } ,
46+ { name : 'bar' , team : 'b' } ,
47+ { name : 'baz' , team : 'a' } ,
48+ { name : 'bag' , team : 'a' }
49+ ] ;
50+ scope . search = '' ;
51+ var elm = angular . element (
52+ '<ul>' +
53+ '<li ng-repeat="players in list | filter: search | chunkBy: 3">' +
54+ '<p ng-repeat="player in players"> {{ player }}</p>' +
55+ '</li>' +
56+ '</ul>'
57+ ) ;
58+ var temp = $compile ( elm ) ( scope ) ;
59+ expect ( function ( ) { scope . $digest ( ) } ) . not . toThrow ( ) ;
60+ expect ( angular . element ( temp . children ( ) [ 0 ] ) . children ( ) . length ) . toEqual ( 3 ) ;
61+ expect ( angular . element ( temp . children ( ) [ 1 ] ) . children ( ) . length ) . toEqual ( 2 ) ;
62+ } ) ) ;
63+ } ) ;
3864} ) ;
0 commit comments