Skip to content

Commit fcee0bc

Browse files
committed
test(chunkBy): test behavior inside the DOM
1 parent fbc4ad7 commit fcee0bc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

test/spec/filter/collection/chunk-by.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
});

test/spec/filter/collection/group-by.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,4 @@ describe('groupByFilter', function() {
9090
expect(temp.children().length).toEqual(2);
9191
}));
9292
});
93-
9493
});

0 commit comments

Comments
 (0)