1
- describe ( 'pager directive' , function ( ) {
2
- var $compile , $rootScope , $document , $templateCache , element ;
1
+ describe ( 'pager directive' , function ( ) {
2
+ var $compile , $rootScope , $document , $templateCache , body , element ;
3
3
beforeEach ( module ( 'ui.bootstrap.pagination' ) ) ;
4
4
beforeEach ( module ( 'template/pagination/pager.html' ) ) ;
5
5
beforeEach ( inject ( function ( _$compile_ , _$rootScope_ , _$document_ , _$templateCache_ ) {
@@ -9,6 +9,7 @@ describe('pager directive', function () {
9
9
$rootScope . currentPage = 3 ;
10
10
$document = _$document_ ;
11
11
$templateCache = _$templateCache_ ;
12
+ body = $document . find ( 'body' ) ;
12
13
element = $compile ( '<pager total-items="total" ng-model="currentPage"></pager>' ) ( $rootScope ) ;
13
14
$rootScope . $digest ( ) ;
14
15
} ) ) ;
@@ -117,8 +118,8 @@ describe('pager directive', function () {
117
118
expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'Next »' ) ;
118
119
} ) ;
119
120
120
- it ( 'should blur the "next" link after it has been clicked' , function ( ) {
121
- $document . find ( ' body' ) . append ( element ) ;
121
+ it ( 'should blur the "next" link after it has been clicked' , function ( ) {
122
+ body . append ( element ) ;
122
123
var linkEl = getPaginationLinkEl ( element , - 1 ) ;
123
124
124
125
linkEl . focus ( ) ;
@@ -130,8 +131,8 @@ describe('pager directive', function () {
130
131
element . remove ( ) ;
131
132
} ) ;
132
133
133
- it ( 'should blur the "prev" link after it has been clicked' , function ( ) {
134
- $document . find ( ' body' ) . append ( element ) ;
134
+ it ( 'should blur the "prev" link after it has been clicked' , function ( ) {
135
+ body . append ( element ) ;
135
136
var linkEl = getPaginationLinkEl ( element , - 1 ) ;
136
137
137
138
linkEl . focus ( ) ;
@@ -152,7 +153,7 @@ describe('pager directive', function () {
152
153
expect ( element . html ( ) ) . toBe ( 'baz' ) ;
153
154
} ) ;
154
155
155
- describe ( '`items-per-page`' , function ( ) {
156
+ describe ( '`items-per-page`' , function ( ) {
156
157
beforeEach ( function ( ) {
157
158
$rootScope . perpage = 5 ;
158
159
element = $compile ( '<pager total-items="total" items-per-page="perpage" ng-model="currentPage"></pager>' ) ( $rootScope ) ;
@@ -176,7 +177,7 @@ describe('pager directive', function () {
176
177
} ) ;
177
178
} ) ;
178
179
179
- describe ( 'when `page` is not a number' , function ( ) {
180
+ describe ( 'when `page` is not a number' , function ( ) {
180
181
it ( 'handles string' , function ( ) {
181
182
updateCurrentPage ( '1' ) ;
182
183
expect ( getPaginationEl ( 0 ) ) . toHaveClass ( 'disabled' ) ;
@@ -186,7 +187,7 @@ describe('pager directive', function () {
186
187
} ) ;
187
188
} ) ;
188
189
189
- describe ( '`num-pages`' , function ( ) {
190
+ describe ( '`num-pages`' , function ( ) {
190
191
beforeEach ( function ( ) {
191
192
$rootScope . numpg = null ;
192
193
element = $compile ( '<pager total-items="total" ng-model="currentPage" num-pages="numpg"></pager>' ) ( $rootScope ) ;
@@ -213,18 +214,18 @@ describe('pager directive', function () {
213
214
angular . extend ( pagerConfig , originalConfig ) ;
214
215
} ) ) ;
215
216
216
- it ( 'should change paging text' , function ( ) {
217
+ it ( 'should change paging text' , function ( ) {
217
218
expect ( getPaginationEl ( 0 ) . text ( ) ) . toBe ( 'PR' ) ;
218
219
expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( 'NE' ) ;
219
220
} ) ;
220
221
221
- it ( 'should not align previous & next page link' , function ( ) {
222
+ it ( 'should not align previous & next page link' , function ( ) {
222
223
expect ( getPaginationEl ( 0 ) ) . not . toHaveClass ( 'previous' ) ;
223
224
expect ( getPaginationEl ( - 1 ) ) . not . toHaveClass ( 'next' ) ;
224
225
} ) ;
225
226
} ) ;
226
227
227
- describe ( 'override configuration from attributes' , function ( ) {
228
+ describe ( 'override configuration from attributes' , function ( ) {
228
229
beforeEach ( function ( ) {
229
230
element = $compile ( '<pager align="false" previous-text="<" next-text=">" total-items="total" ng-model="currentPage"></pager>' ) ( $rootScope ) ;
230
231
$rootScope . $digest ( ) ;
@@ -234,12 +235,12 @@ describe('pager directive', function () {
234
235
expect ( getPaginationBarSize ( ) ) . toBe ( 2 ) ;
235
236
} ) ;
236
237
237
- it ( 'should change paging text from attributes' , function ( ) {
238
+ it ( 'should change paging text from attributes' , function ( ) {
238
239
expect ( getPaginationEl ( 0 ) . text ( ) ) . toBe ( '<' ) ;
239
240
expect ( getPaginationEl ( - 1 ) . text ( ) ) . toBe ( '>' ) ;
240
241
} ) ;
241
242
242
- it ( 'should not align previous & next page link' , function ( ) {
243
+ it ( 'should not align previous & next page link' , function ( ) {
243
244
expect ( getPaginationEl ( 0 ) ) . not . toHaveClass ( 'previous' ) ;
244
245
expect ( getPaginationEl ( - 1 ) ) . not . toHaveClass ( 'next' ) ;
245
246
} ) ;
0 commit comments