Skip to content

Commit bb9203e

Browse files
dirPagination: Add a couple of test cases for "track by" syntax
1 parent de1ce3f commit bb9203e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/directives/pagination/dirPagination.spec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,36 @@ describe('dirPagination directive', function() {
274274
expect($scope.alias2.length).toEqual(10);
275275
});
276276

277+
it('should allow dot and bracket notation', function() {
278+
function compile() {
279+
$scope.foo = {
280+
name: 'myCollection',
281+
myCollection: myCollection,
282+
perPage: 10
283+
};
284+
compileElement(myCollection, 5, 1, "item in foo[foo.name] | itemsPerPage:foo.perPage");
285+
}
286+
expect(compile).not.toThrow();
287+
expect(getListItems().length).toEqual(10);
288+
});
289+
290+
291+
it('should allow track by syntax 1', function() {
292+
function compile() {
293+
compileElement(myCollection, 5, 1, "item in collection | itemsPerPage: 10 track by $index");
294+
}
295+
expect(compile).not.toThrow();
296+
expect(getListItems().length).toEqual(10);
297+
});
298+
299+
it('should allow track by syntax 2', function() {
300+
function compile() {
301+
compileElement(myCollection, 5, 1, "item in collection | itemsPerPage: 10 track by item");
302+
}
303+
expect(compile).not.toThrow();
304+
expect(getListItems().length).toEqual(10);
305+
});
306+
277307
});
278308

279309
describe('if currentPage attribute is not set', function() {

0 commit comments

Comments
 (0)