-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pagination): Add tests for pagination.
- 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.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
app/scripts/components/ui/pagination/tests/pagination.controller.tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
})); | ||
|
||
}); | ||
|
||
}); |