@@ -95,6 +95,26 @@ describe('pagination directive', function () {
9595 expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'Next' ) ;
9696 } ) ;
9797
98+ it ( 'does not "break" when `total-items` is undefined' , function ( ) {
99+ $rootScope . total = undefined ;
100+ $rootScope . $digest ( ) ;
101+
102+ expect ( getPaginationBarSize ( ) ) . toBe ( 3 ) ; // Previous, 1, Next
103+ expect ( getPaginationEl ( 0 ) ) . toHaveClass ( 'disabled' ) ;
104+ expect ( getPaginationEl ( 1 ) ) . toHaveClass ( 'active' ) ;
105+ expect ( getPaginationEl ( 2 ) ) . toHaveClass ( 'disabled' ) ;
106+ } ) ;
107+
108+ it ( 'does not "break" when `total-items` is negative' , function ( ) {
109+ $rootScope . total = - 1 ;
110+ $rootScope . $digest ( ) ;
111+
112+ expect ( getPaginationBarSize ( ) ) . toBe ( 3 ) ; // Previous, 1, Next
113+ expect ( getPaginationEl ( 0 ) ) . toHaveClass ( 'disabled' ) ;
114+ expect ( getPaginationEl ( 1 ) ) . toHaveClass ( 'active' ) ;
115+ expect ( getPaginationEl ( 2 ) ) . toHaveClass ( 'disabled' ) ;
116+ } ) ;
117+
98118 it ( 'does not change the current page when `total-items` changes but is valid' , function ( ) {
99119 $rootScope . currentPage = 1 ;
100120 $rootScope . total = 18 ; // 2 pages
@@ -495,6 +515,15 @@ describe('pagination directive', function () {
495515 expect ( $rootScope . numpg ) . toBe ( 8 ) ;
496516 } ) ;
497517
518+ it ( 'shows minimun one page if total items are not defined and does not break binding' , function ( ) {
519+ $rootScope . total = undefined ;
520+ $rootScope . $digest ( ) ;
521+ expect ( $rootScope . numpg ) . toBe ( 1 ) ;
522+
523+ $rootScope . total = 73 ; // 8 pages
524+ $rootScope . $digest ( ) ;
525+ expect ( $rootScope . numpg ) . toBe ( 8 ) ;
526+ } ) ;
498527 } ) ;
499528
500529 describe ( 'setting `paginationConfig`' , function ( ) {
0 commit comments