Skip to content

Commit

Permalink
test(ngTable): increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrowhurstram committed Feb 15, 2015
1 parent ea970a0 commit 2705b94
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/tableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ describe('ng-table', function() {
$compile(elm)(scope);
scope.$digest();

// 'text' is a shortcut alias for the template ng-table/filters/text
scope.usernameFilter = {username: 'text'};
scope.tableParams = new NgTableParams({}, {});
scope.$digest();
Expand All @@ -317,6 +318,24 @@ describe('ng-table', function() {
expect($capturedColumn.filter).toBeDefined();
expect($capturedColumn.filter()['username']).toBe('text');
});

it('when filter changes should reset page number to 1', inject(function ($timeout) {
// trigger initial load of data so that subsequent changes to filter will trigger reset of page #
scope.tableParams.filter()['username'] = 'initial value';
scope.$digest();
$timeout.flush(); // trigger delayed filter

// set page to something other than 1
scope.tableParams.page(5);
expect(scope.tableParams.page()).toBe(5); // checking assumptions

// when
scope.tableParams.filter()['username'] = 'new value';
scope.$digest();
$timeout.flush(); // trigger delayed filter

expect(scope.tableParams.page()).toBe(1);
}));
});

describe('filter specified with url', function(){
Expand Down

0 comments on commit 2705b94

Please sign in to comment.