Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(pagination): take maxSize defaults into account
Browse files Browse the repository at this point in the history
Fixes #1728
Closes #1738
  • Loading branch information
pkozlowski-opensource committed Feb 8, 2014
1 parent b7eb69e commit a294c87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/pagination/pagination.js
Expand Up @@ -104,7 +104,7 @@ angular.module('ui.bootstrap.pagination', [])
}

// Setup configuration parameters
var maxSize,
var maxSize = paginationCtrl.getAttributeValue(attrs.maxSize, config.maxSize ),
boundaryLinks = paginationCtrl.getAttributeValue(attrs.boundaryLinks, config.boundaryLinks ),
directionLinks = paginationCtrl.getAttributeValue(attrs.directionLinks, config.directionLinks ),
firstText = paginationCtrl.getAttributeValue(attrs.firstText, config.firstText, true),
Expand Down
37 changes: 25 additions & 12 deletions src/pagination/test/pagination.spec.js
Expand Up @@ -529,10 +529,17 @@ describe('pagination directive', function () {
});

describe('setting `paginationConfig`', function() {
var originalConfig = {};
beforeEach(inject(function(paginationConfig) {
angular.extend(originalConfig, paginationConfig);
paginationConfig.itemsPerPage = 5;
var originalConfig, paginationConfig;
beforeEach(inject(function(_paginationConfig_) {
originalConfig = angular.copy(_paginationConfig_);
paginationConfig = _paginationConfig_;
}));
afterEach(inject(function(paginationConfig) {
// return it to the original stat
angular.copy(originalConfig, paginationConfig);
}));

it('should change paging text', function () {
paginationConfig.boundaryLinks = true;
paginationConfig.directionLinks = true;
paginationConfig.firstText = 'FI';
Expand All @@ -541,21 +548,27 @@ describe('pagination directive', function () {
paginationConfig.lastText = 'LA';
element = $compile('<pagination total-items="total" ng-model="currentPage"></pagination>')($rootScope);
$rootScope.$digest();
}));
afterEach(inject(function(paginationConfig) {
// return it to the original stat
angular.extend(paginationConfig, originalConfig);
}));

it('should change paging text', function () {
expect(getPaginationEl(0).text()).toBe('FI');
expect(getPaginationEl(1).text()).toBe('PR');
expect(getPaginationEl(-2).text()).toBe('NE');
expect(getPaginationEl(-1).text()).toBe('LA');
});

it('contains number of pages + 4 li elements', function() {
expect(getPaginationBarSize()).toBe(14);
it('contains number of pages + 2 li elements', function() {
paginationConfig.itemsPerPage = 5;
element = $compile('<pagination total-items="total" ng-model="currentPage"></pagination>')($rootScope);
$rootScope.$digest();

expect(getPaginationBarSize()).toBe(12);
});

it('should take maxSize defaults into account', function () {
paginationConfig.maxSize = 2;
element = $compile('<pagination total-items="total" ng-model="currentPage"></pagination>')($rootScope);
$rootScope.$digest();

expect(getPaginationBarSize()).toBe(4);
});
});

Expand Down

0 comments on commit a294c87

Please sign in to comment.