@@ -95,6 +95,26 @@ describe('pagination directive', function () {
95
95
expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'Next' ) ;
96
96
} ) ;
97
97
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
+
98
118
it ( 'does not change the current page when `total-items` changes but is valid' , function ( ) {
99
119
$rootScope . currentPage = 1 ;
100
120
$rootScope . total = 18 ; // 2 pages
@@ -495,6 +515,15 @@ describe('pagination directive', function () {
495
515
expect ( $rootScope . numpg ) . toBe ( 8 ) ;
496
516
} ) ;
497
517
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
+ } ) ;
498
527
} ) ;
499
528
500
529
describe ( 'setting `paginationConfig`' , function ( ) {
0 commit comments