@@ -529,10 +529,17 @@ describe('pagination directive', function () {
529
529
} ) ;
530
530
531
531
describe ( 'setting `paginationConfig`' , function ( ) {
532
- var originalConfig = { } ;
533
- beforeEach ( inject ( function ( paginationConfig ) {
534
- angular . extend ( originalConfig , paginationConfig ) ;
535
- paginationConfig . itemsPerPage = 5 ;
532
+ var originalConfig , paginationConfig ;
533
+ beforeEach ( inject ( function ( _paginationConfig_ ) {
534
+ originalConfig = angular . copy ( _paginationConfig_ ) ;
535
+ paginationConfig = _paginationConfig_ ;
536
+ } ) ) ;
537
+ afterEach ( inject ( function ( paginationConfig ) {
538
+ // return it to the original stat
539
+ angular . copy ( originalConfig , paginationConfig ) ;
540
+ } ) ) ;
541
+
542
+ it ( 'should change paging text' , function ( ) {
536
543
paginationConfig . boundaryLinks = true ;
537
544
paginationConfig . directionLinks = true ;
538
545
paginationConfig . firstText = 'FI' ;
@@ -541,21 +548,27 @@ describe('pagination directive', function () {
541
548
paginationConfig . lastText = 'LA' ;
542
549
element = $compile ( '<pagination total-items="total" ng-model="currentPage"></pagination>' ) ( $rootScope ) ;
543
550
$rootScope . $digest ( ) ;
544
- } ) ) ;
545
- afterEach ( inject ( function ( paginationConfig ) {
546
- // return it to the original stat
547
- angular . extend ( paginationConfig , originalConfig ) ;
548
- } ) ) ;
549
551
550
- it ( 'should change paging text' , function ( ) {
551
552
expect ( getPaginationEl ( 0 ) . text ( ) ) . toBe ( 'FI' ) ;
552
553
expect ( getPaginationEl ( 1 ) . text ( ) ) . toBe ( 'PR' ) ;
553
554
expect ( getPaginationEl ( - 2 ) . text ( ) ) . toBe ( 'NE' ) ;
554
555
expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'LA' ) ;
555
556
} ) ;
556
557
557
- it ( 'contains number of pages + 4 li elements' , function ( ) {
558
- expect ( getPaginationBarSize ( ) ) . toBe ( 14 ) ;
558
+ it ( 'contains number of pages + 2 li elements' , function ( ) {
559
+ paginationConfig . itemsPerPage = 5 ;
560
+ element = $compile ( '<pagination total-items="total" ng-model="currentPage"></pagination>' ) ( $rootScope ) ;
561
+ $rootScope . $digest ( ) ;
562
+
563
+ expect ( getPaginationBarSize ( ) ) . toBe ( 12 ) ;
564
+ } ) ;
565
+
566
+ it ( 'should take maxSize defaults into account' , function ( ) {
567
+ paginationConfig . maxSize = 2 ;
568
+ element = $compile ( '<pagination total-items="total" ng-model="currentPage"></pagination>' ) ( $rootScope ) ;
569
+ $rootScope . $digest ( ) ;
570
+
571
+ expect ( getPaginationBarSize ( ) ) . toBe ( 4 ) ;
559
572
} ) ;
560
573
} ) ;
561
574
0 commit comments