Skip to content

Commit

Permalink
chore(pagination): Add tests for pagination.
Browse files Browse the repository at this point in the history
- Adds tests focused on the PagingController used in the directive.

Closes #274
  • Loading branch information
Matthew Schranz committed Feb 2, 2015
1 parent 2890b07 commit 53a0de2
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
describe('Pagination:', function () {

// Initialization of the AngularJS application before each test case
beforeEach(module('ngApp.components', 'location.services'));

describe('PagingController:', function () {

it('should update url with paging changes with no update', inject(function ($rootScope, $controller, LocationService) {
var scope = $rootScope.$new();
scope.paging = {
page: 1,
size: 10,
from: 1
};
scope.page = "test";

var wc = $controller('PagingController', { $scope: scope, LocationService: LocationService });
wc.refresh();

var paging = LocationService.pagination()[scope.page];
expect(paging.size).to.equal(10);
expect(paging.from).to.equal(1);
}));

it('should emit event for custom update', inject(function ($rootScope, $controller, LocationService) {
var scope = $rootScope.$new();
scope.paging = {
page: 1,
size: 10,
from: 1
};
scope.update = true;
scope.page = "test";

var wc = $controller('PagingController', { $scope: scope, LocationService: LocationService });
var emitCallBack = sinon.spy(scope, "$emit");
wc.refresh();
expect(emitCallBack).to.have.been.calledOnce;
}));

it('should update paging size', inject(function ($rootScope, $controller, LocationService) {
var scope = $rootScope.$new();
scope.paging = {
page: 1,
size: 10,
from: 1
};
scope.page = "test";

var wc = $controller('PagingController', { $scope: scope, LocationService: LocationService });
var refreshCallBack = sinon.spy(wc, "refresh");
wc.setCount({}, 25);
expect(refreshCallBack).to.have.been.calledOnce;
expect(scope.paging.size).to.equal(25);
}));

});

});

0 comments on commit 53a0de2

Please sign in to comment.