Skip to content

Commit d52548a

Browse files
committed
rebase
1 parent 746c3db commit d52548a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/demo-app/data-table/person-data-source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {CollectionViewer, DataSource, MdPaginator, PageEvent} from '@angular/material';
1+
import {CollectionViewer, DataSource, MdPaginator} from '@angular/material';
22
import {Observable} from 'rxjs/Observable';
33
import {PeopleDatabase, UserData} from './people-database';
44
import {BehaviorSubject} from 'rxjs/BehaviorSubject';

src/lib/paginator/paginator.spec.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing';
22
import {MdPaginatorModule} from './index';
33
import {MdPaginator, PageEvent} from './paginator';
44
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';
95
import {MdPaginatorIntl} from './paginator-intl';
106
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
117
import {customMatchers} from '../core/testing/jasmine-matchers';
@@ -106,7 +102,7 @@ describe('MdPaginator', () => {
106102
component.clickNextButton();
107103

108104
expect(paginator.pageIndex).toBe(1);
109-
expect(component.latestPageEvent.pageIndex).toBe(1);
105+
expect(component.latestPageEvent ? component.latestPageEvent.pageIndex : null).toBe(1);
110106
});
111107

112108
it('should be able to go to the previous page', () => {
@@ -117,7 +113,7 @@ describe('MdPaginator', () => {
117113
component.clickPreviousButton();
118114

119115
expect(paginator.pageIndex).toBe(0);
120-
expect(component.latestPageEvent.pageIndex).toBe(0);
116+
expect(component.latestPageEvent ? component.latestPageEvent.pageIndex : null).toBe(0);
121117
});
122118

123119
it('should disable navigating to the next page if at first page', () => {
@@ -174,32 +170,35 @@ describe('MdPaginator', () => {
174170
fixture.detectChanges();
175171

176172
// 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;
178174
expect(firstPageItemIndex).toBe(40);
179175

180176
// The first item on the page is now 25. Change the page size to 25 so that we should now be
181177
// on the second page where the top item is index 25.
182178
paginator._changePageSize(25);
183179
let paginationEvent = component.latestPageEvent;
184-
firstPageItemIndex = paginationEvent.pageIndex * paginationEvent.pageSize;
180+
firstPageItemIndex = paginationEvent ?
181+
paginationEvent.pageIndex * paginationEvent.pageSize : null;
185182
expect(firstPageItemIndex).toBe(25);
186-
expect(paginationEvent.pageIndex).toBe(1);
183+
expect(paginationEvent ? paginationEvent.pageIndex : null).toBe(1);
187184

188185
// The first item on the page is still 25. Change the page size to 8 so that we should now be
189186
// on the fourth page where the top item is index 24.
190187
paginator._changePageSize(8);
191188
paginationEvent = component.latestPageEvent;
192-
firstPageItemIndex = paginationEvent.pageIndex * paginationEvent.pageSize;
189+
firstPageItemIndex = paginationEvent ?
190+
paginationEvent.pageIndex * paginationEvent.pageSize : null;
193191
expect(firstPageItemIndex).toBe(24);
194-
expect(paginationEvent.pageIndex).toBe(3);
192+
expect(paginationEvent ? paginationEvent.pageIndex : null).toBe(3);
195193

196194
// The first item on the page is 24. Change the page size to 16 so that we should now be
197195
// on the first page where the top item is index 0.
198196
paginator._changePageSize(25);
199197
paginationEvent = component.latestPageEvent;
200-
firstPageItemIndex = paginationEvent.pageIndex * paginationEvent.pageSize;
198+
firstPageItemIndex = paginationEvent ?
199+
paginationEvent.pageIndex * paginationEvent.pageSize : null;
201200
expect(firstPageItemIndex).toBe(0);
202-
expect(paginationEvent.pageIndex).toBe(0);
201+
expect(paginationEvent ? paginationEvent.pageIndex : null).toBe(0);
203202
});
204203

205204
it('should show a select only if there are multiple options', () => {
@@ -230,7 +229,7 @@ class MdPaginatorApp {
230229
pageSizeOptions = [5, 10, 25, 100];
231230
length = 100;
232231

233-
latestPageEvent: PageEvent;
232+
latestPageEvent: PageEvent | null;
234233

235234
@ViewChild(MdPaginator) mdPaginator: MdPaginator;
236235

0 commit comments

Comments
 (0)