mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
wrote unit test for pagination detection service
This commit is contained in:
parent
7b12954127
commit
53cf824602
@ -4,7 +4,7 @@
|
||||
* All Rights Reserved
|
||||
*************************************************/
|
||||
|
||||
export default ['$q', '$http', function($q, $http) {
|
||||
export default ['$http', function($http) {
|
||||
return {
|
||||
getInitialPageForList: function(id, url, pageSize) {
|
||||
// get the name of the object
|
||||
|
||||
39
awx/ui/client/tests/services/pagination.service-test.js
Normal file
39
awx/ui/client/tests/services/pagination.service-test.js
Normal file
@ -0,0 +1,39 @@
|
||||
import '../support/node';
|
||||
|
||||
import paginationModule from 'shared/pagination/main';
|
||||
|
||||
describe("pagination.service", function() {
|
||||
var $httpBackend, pagination;
|
||||
|
||||
beforeEach("instantiate the pagination module", function() {
|
||||
angular.mock.module(paginationModule.name);
|
||||
});
|
||||
|
||||
beforeEach("put the service and deps in scope", inject(function($injector) {
|
||||
$httpBackend = $injector.get('$httpBackend');
|
||||
pagination = $injector.get('pagination');
|
||||
}));
|
||||
|
||||
afterEach(function() {
|
||||
$httpBackend.verifyNoOutstandingExpectation();
|
||||
$httpBackend.verifyNoOutstandingRequest();
|
||||
});
|
||||
|
||||
describe("should return page given obj is on", function() {
|
||||
it('should return true', function() {
|
||||
// get the name of the object
|
||||
$httpBackend.when('GET', '/url/?id=1')
|
||||
.respond({results: [{name: "foo"}]});
|
||||
// get how many results are less than or equal to
|
||||
// the name
|
||||
$httpBackend.when('GET', '/url/?name__lte=foo')
|
||||
.respond({count: 24});
|
||||
|
||||
|
||||
var page = pagination.getInitialPageForList("1", "/url/", 20);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(page).to.eventually.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user