@@ -2,10 +2,6 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2
2
import { MdPaginatorModule } from './index' ;
3
3
import { MdPaginator , PageEvent } from './paginator' ;
4
4
import { Component , ElementRef , ViewChild } from '@angular/core' ;
5
- import { MdCommonModule } from '../core' ;
6
- import { MdSelectModule } from '../select/index' ;
7
- import { MdTooltipModule } from '../tooltip/index' ;
8
- import { MdButtonModule } from '../button/index' ;
9
5
import { MdPaginatorIntl } from './paginator-intl' ;
10
6
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
11
7
import { customMatchers } from '../core/testing/jasmine-matchers' ;
@@ -106,7 +102,7 @@ describe('MdPaginator', () => {
106
102
component . clickNextButton ( ) ;
107
103
108
104
expect ( paginator . pageIndex ) . toBe ( 1 ) ;
109
- expect ( component . latestPageEvent . pageIndex ) . toBe ( 1 ) ;
105
+ expect ( component . latestPageEvent ? component . latestPageEvent . pageIndex : null ) . toBe ( 1 ) ;
110
106
} ) ;
111
107
112
108
it ( 'should be able to go to the previous page' , ( ) => {
@@ -117,7 +113,7 @@ describe('MdPaginator', () => {
117
113
component . clickPreviousButton ( ) ;
118
114
119
115
expect ( paginator . pageIndex ) . toBe ( 0 ) ;
120
- expect ( component . latestPageEvent . pageIndex ) . toBe ( 0 ) ;
116
+ expect ( component . latestPageEvent ? component . latestPageEvent . pageIndex : null ) . toBe ( 0 ) ;
121
117
} ) ;
122
118
123
119
it ( 'should disable navigating to the next page if at first page' , ( ) => {
@@ -174,32 +170,35 @@ describe('MdPaginator', () => {
174
170
fixture . detectChanges ( ) ;
175
171
176
172
// The first item of the page should be item with index 40
177
- let firstPageItemIndex = paginator . pageIndex * paginator . pageSize ;
173
+ let firstPageItemIndex : number | null = paginator . pageIndex * paginator . pageSize ;
178
174
expect ( firstPageItemIndex ) . toBe ( 40 ) ;
179
175
180
176
// The first item on the page is now 25. Change the page size to 25 so that we should now be
181
177
// on the second page where the top item is index 25.
182
178
paginator . _changePageSize ( 25 ) ;
183
179
let paginationEvent = component . latestPageEvent ;
184
- firstPageItemIndex = paginationEvent . pageIndex * paginationEvent . pageSize ;
180
+ firstPageItemIndex = paginationEvent ?
181
+ paginationEvent . pageIndex * paginationEvent . pageSize : null ;
185
182
expect ( firstPageItemIndex ) . toBe ( 25 ) ;
186
- expect ( paginationEvent . pageIndex ) . toBe ( 1 ) ;
183
+ expect ( paginationEvent ? paginationEvent . pageIndex : null ) . toBe ( 1 ) ;
187
184
188
185
// The first item on the page is still 25. Change the page size to 8 so that we should now be
189
186
// on the fourth page where the top item is index 24.
190
187
paginator . _changePageSize ( 8 ) ;
191
188
paginationEvent = component . latestPageEvent ;
192
- firstPageItemIndex = paginationEvent . pageIndex * paginationEvent . pageSize ;
189
+ firstPageItemIndex = paginationEvent ?
190
+ paginationEvent . pageIndex * paginationEvent . pageSize : null ;
193
191
expect ( firstPageItemIndex ) . toBe ( 24 ) ;
194
- expect ( paginationEvent . pageIndex ) . toBe ( 3 ) ;
192
+ expect ( paginationEvent ? paginationEvent . pageIndex : null ) . toBe ( 3 ) ;
195
193
196
194
// The first item on the page is 24. Change the page size to 16 so that we should now be
197
195
// on the first page where the top item is index 0.
198
196
paginator . _changePageSize ( 25 ) ;
199
197
paginationEvent = component . latestPageEvent ;
200
- firstPageItemIndex = paginationEvent . pageIndex * paginationEvent . pageSize ;
198
+ firstPageItemIndex = paginationEvent ?
199
+ paginationEvent . pageIndex * paginationEvent . pageSize : null ;
201
200
expect ( firstPageItemIndex ) . toBe ( 0 ) ;
202
- expect ( paginationEvent . pageIndex ) . toBe ( 0 ) ;
201
+ expect ( paginationEvent ? paginationEvent . pageIndex : null ) . toBe ( 0 ) ;
203
202
} ) ;
204
203
205
204
it ( 'should show a select only if there are multiple options' , ( ) => {
@@ -230,7 +229,7 @@ class MdPaginatorApp {
230
229
pageSizeOptions = [ 5 , 10 , 25 , 100 ] ;
231
230
length = 100 ;
232
231
233
- latestPageEvent : PageEvent ;
232
+ latestPageEvent : PageEvent | null ;
234
233
235
234
@ViewChild ( MdPaginator ) mdPaginator : MdPaginator ;
236
235
0 commit comments