@@ -529,10 +529,17 @@ describe('pagination directive', function () {
529529 } ) ;
530530
531531 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 ( ) {
536543 paginationConfig . boundaryLinks = true ;
537544 paginationConfig . directionLinks = true ;
538545 paginationConfig . firstText = 'FI' ;
@@ -541,21 +548,27 @@ describe('pagination directive', function () {
541548 paginationConfig . lastText = 'LA' ;
542549 element = $compile ( '<pagination total-items="total" ng-model="currentPage"></pagination>' ) ( $rootScope ) ;
543550 $rootScope . $digest ( ) ;
544- } ) ) ;
545- afterEach ( inject ( function ( paginationConfig ) {
546- // return it to the original stat
547- angular . extend ( paginationConfig , originalConfig ) ;
548- } ) ) ;
549551
550- it ( 'should change paging text' , function ( ) {
551552 expect ( getPaginationEl ( 0 ) . text ( ) ) . toBe ( 'FI' ) ;
552553 expect ( getPaginationEl ( 1 ) . text ( ) ) . toBe ( 'PR' ) ;
553554 expect ( getPaginationEl ( - 2 ) . text ( ) ) . toBe ( 'NE' ) ;
554555 expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'LA' ) ;
555556 } ) ;
556557
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 ) ;
559572 } ) ;
560573 } ) ;
561574
0 commit comments