diff --git a/awx/ui/client/src/shared/pagination/pagination.service.js b/awx/ui/client/src/shared/pagination/pagination.service.js index f18d7890e9..96cdfb4c3e 100644 --- a/awx/ui/client/src/shared/pagination/pagination.service.js +++ b/awx/ui/client/src/shared/pagination/pagination.service.js @@ -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 diff --git a/awx/ui/client/tests/services/pagination.service-test.js b/awx/ui/client/tests/services/pagination.service-test.js new file mode 100644 index 0000000000..2b64d3c2ea --- /dev/null +++ b/awx/ui/client/tests/services/pagination.service-test.js @@ -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); + }); + }); +});