@@ -129,11 +129,59 @@ describe('IgxGrid Master Detail', () => {
129
129
} ) ;
130
130
} ) ;
131
131
} ) ;
132
+
133
+ describe ( 'Integration' , ( ) => {
134
+ configureTestSuite ( ) ;
135
+ beforeEach ( async ( ( ) => {
136
+ TestBed . configureTestingModule ( {
137
+ declarations : [
138
+ DefaultGridMasterDetailComponent
139
+ ] ,
140
+ imports : [ IgxGridModule , NoopAnimationsModule ]
141
+ } ) . compileComponents ( ) ;
142
+ } ) ) ;
143
+
144
+ describe ( 'Paging' , ( ) => {
145
+ it ( 'Should not take into account expanded detail views as additional records.' , ( ) => {
146
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
147
+ fix . componentInstance . paging = true ;
148
+ grid = fix . componentInstance . grid ;
149
+ fix . detectChanges ( ) ;
150
+ const initialTotalRecords = grid . pagingState . metadata . countRecords ;
151
+ grid . expand ( fix . componentInstance . data [ 0 ] . ID ) ;
152
+ fix . detectChanges ( ) ;
153
+ expect ( grid . pagingState . metadata . countRecords ) . toEqual ( initialTotalRecords ) ;
154
+ } ) ;
155
+
156
+ it ( 'Should persist template state after paging to a page with fewer records and paging back.' , ( ) => {
157
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
158
+ fix . componentInstance . paging = true ;
159
+ fix . componentInstance . perPage = 5 ;
160
+ grid = fix . componentInstance . grid ;
161
+ fix . detectChanges ( ) ;
162
+ grid . expand ( fix . componentInstance . data [ 4 ] . ID ) ;
163
+ fix . detectChanges ( ) ;
164
+ // click the template checkbox
165
+ let checkbox = fix . debugElement . query ( By . css ( '.igx-checkbox__input' ) ) ;
166
+ checkbox . nativeElement . click ( ) ;
167
+ fix . detectChanges ( ) ;
168
+ // go to last page that doesn't contain this view
169
+ grid . page = grid . pagingState . metadata . countPages - 1 ;
170
+ fix . detectChanges ( ) ;
171
+ // go back to first page
172
+ grid . page = 0 ;
173
+ fix . detectChanges ( ) ;
174
+ // check checkbox state
175
+ checkbox = fix . debugElement . query ( By . css ( '.igx-checkbox__input' ) ) ;
176
+ expect ( checkbox . nativeElement . attributes [ 'aria-checked' ] . value ) . toEqual ( 'true' ) ;
177
+ } ) ;
178
+ } ) ;
179
+ } ) ;
132
180
} ) ;
133
181
134
182
@Component ( {
135
183
template : `
136
- <igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [rowSelectable]="rowSelectable">
184
+ <igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [perPage]="perPage" [ rowSelectable]="rowSelectable">
137
185
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'
138
186
[hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable"
139
187
[hasSummary]="c.hasSummary" [pinned]='c.pinned'>
@@ -162,8 +210,11 @@ export class DefaultGridMasterDetailComponent {
162
210
{ field : 'CompanyName' , width : 400 , dataType : 'string' }
163
211
] ;
164
212
public paging = false ;
213
+ public perPage = 15 ;
165
214
public rowSelectable = false ;
166
215
216
+ public onCheckboxClicked = ( ) => { } ;
217
+
167
218
@ViewChild ( IgxGridComponent , { read : IgxGridComponent , static : true } )
168
219
public grid : IgxGridComponent ;
169
220
0 commit comments