@@ -23,6 +23,7 @@ describe(`Update to ${version}`, () => {
23
23
} ;
24
24
25
25
const migrationName = 'migration-21' ;
26
+ const lineBreaksAndSpaceRegex = / \s / g;
26
27
// eslint-disable-next-line max-len
27
28
const noteText = `<!--NOTE: This component has been updated by Infragistics migration: v${ version } \nPlease check your template whether all bindings/event handlers are correct.-->` ;
28
29
@@ -194,4 +195,182 @@ export class TestComponent implements OnInit {
194
195
</igx-expansion-panel-header>
195
196
</igx-expansion-panel>` ) ;
196
197
} ) ;
198
+
199
+ it ( 'should remove paging property and define a igx-paginator component instead' , async ( ) => {
200
+ appTree . create (
201
+ '/testSrc/appPrefix/component/test.component.html' , `
202
+ <igx-grid #grid1 [data]="data" [paging]="someVal" [perPage]="10" height="300px" width="300px">
203
+ <igx-column field="Name" header="Athlete"></igx-column>
204
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
205
+ <igx-column field="CountryFlag" header="Country"></igx-column>
206
+ </igx-grid>` ) ;
207
+ const tree = await schematicRunner . runSchematicAsync ( migrationName , { } , appTree )
208
+ . toPromise ( ) ;
209
+
210
+ expect ( tree . readContent ( '/testSrc/appPrefix/component/test.component.html' ) )
211
+ . toEqual ( `
212
+ <igx-grid #grid1 [data]="data" [perPage]="10" height="300px" width="300px">
213
+ <igx-paginator *ngIf="someVal"></igx-paginator>
214
+ <igx-column field="Name" header="Athlete"></igx-column>
215
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
216
+ <igx-column field="CountryFlag" header="Country"></igx-column>
217
+ </igx-grid>` ) ;
218
+ } ) ;
219
+
220
+ it ( 'should remove paging and paginationTemplate property and define a igx-paginator component with custom content' , async ( ) => {
221
+ appTree . create (
222
+ '/testSrc/appPrefix/component/test.component.html' , `
223
+ <igx-grid #grid1 [data]="data" [paging]="true" [paginationTemplate]="customPager" height="300px" width="300px">
224
+ <igx-column field="Name" header="Athlete"></igx-column>
225
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
226
+ <igx-column field="CountryFlag" header="Country"></igx-column>
227
+ </igx-grid>
228
+ <ng-template #customPager let-api>
229
+ <div class="igx-grid__footer">
230
+ <div id="numberPager" class="igx-paginator" style="justify-content: center;">
231
+ <button [disabled]="firstPage" (click)="previousPage()" igxButton="flat">PREV</button>
232
+ <button [disabled]="lastPage" (click)="nextPage()" igxButton="flat">NEXT</button>
233
+ </div>
234
+ </div>
235
+ </ng-template>` ) ;
236
+ const tree = await schematicRunner . runSchematicAsync ( migrationName , { } , appTree )
237
+ . toPromise ( ) ;
238
+
239
+ expect ( tree . readContent ( '/testSrc/appPrefix/component/test.component.html' ) . replace ( lineBreaksAndSpaceRegex , '' ) )
240
+ . toEqual ( `
241
+ <igx-grid #grid1 [data]="data" height="300px" width="300px">
242
+ <igx-paginator>
243
+ <!-- Auto migrated template content. Please, check your bindings! -->
244
+
245
+ <igx-paginator-content>
246
+
247
+ <div class="igx-grid__footer">
248
+ <div id="numberPager" class="igx-paginator" style="justify-content: center;">
249
+ <button [disabled]="firstPage" (click)="previousPage()" igxButton="flat">PREV</button>
250
+ <button [disabled]="lastPage" (click)="nextPage()" igxButton="flat">NEXT</button>
251
+ </div>
252
+ </div>
253
+
254
+ </igx-paginator-content>
255
+ </igx-paginator>
256
+ <igx-column field="Name" header="Athlete"></igx-column>
257
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
258
+ <igx-column field="CountryFlag" header="Country"></igx-column>
259
+ </igx-grid>
260
+ ` . replace ( lineBreaksAndSpaceRegex , '' ) ) ;
261
+ } ) ;
262
+
263
+ it ( 'should remove paging property and define a igx-paginator component instead in hGrid' , async ( ) => {
264
+ appTree . create (
265
+ '/testSrc/appPrefix/component/test.component.html' , `
266
+ <igx-hierarchical-grid [paging]="parentPaging">
267
+ <igx-column></igx-column>
268
+ <igx-row-island [paging]="childPaging">
269
+ <igx-column></igx-column>
270
+ </igx-row-island>
271
+ </igx-hierarchical-grid>` ) ;
272
+ const tree = await schematicRunner . runSchematicAsync ( migrationName , { } , appTree )
273
+ . toPromise ( ) ;
274
+
275
+ expect ( tree . readContent ( '/testSrc/appPrefix/component/test.component.html' ) )
276
+ . toEqual ( `
277
+ <igx-hierarchical-grid>
278
+ <igx-paginator *ngIf="parentPaging"></igx-paginator>
279
+ <igx-column></igx-column>
280
+ <igx-row-island>
281
+ <igx-paginator *igxPaginator *ngIf="childPaging"></igx-paginator>
282
+ <igx-column></igx-column>
283
+ </igx-row-island>
284
+ </igx-hierarchical-grid>` ) ;
285
+ } ) ;
286
+
287
+ it ( 'should remove paging property and paginationTemplate in hGrid' , async ( ) => {
288
+ appTree . create (
289
+ '/testSrc/appPrefix/component/test.component.html' , `
290
+ <igx-hierarchical-grid [paging]="parentPaging" [paginationTemplate]="myTemplate">
291
+ <igx-column></igx-column>
292
+ <igx-row-island [paging]="childPaging" [paginationTemplate]="childTemplate">
293
+ <igx-column></igx-column>
294
+ </igx-row-island>
295
+ </igx-hierarchical-grid>
296
+ <ng-template #myTemplate>
297
+ <div>
298
+ Current page: {{ hierarchicalGrid.page }}
299
+ </div>
300
+ </ng-template>
301
+ <ng-template #childTemplate>
302
+ <div>
303
+ <button (click)="previous()">PREV</button>
304
+ Current page: {{ hierarchicalGrid.page }}
305
+ <button (click)="next()">NEXT</button>
306
+ </div>
307
+ </ng-template>` ) ;
308
+ const tree = await schematicRunner . runSchematicAsync ( migrationName , { } , appTree )
309
+ . toPromise ( ) ;
310
+
311
+ expect ( tree . readContent ( '/testSrc/appPrefix/component/test.component.html' ) . replace ( lineBreaksAndSpaceRegex , '' ) )
312
+ . toEqual ( `
313
+ <igx-hierarchical-grid>
314
+ <igx-paginator *ngIf="parentPaging">
315
+ <!-- Auto migrated template content. Please, check your bindings! -->
316
+
317
+ <igx-paginator-content>
318
+
319
+ <div>
320
+ Current page: {{ hierarchicalGrid.page }}
321
+ </div>
322
+
323
+ </igx-paginator-content>
324
+ </igx-paginator>
325
+ <igx-column></igx-column>
326
+ <igx-row-island>
327
+ <igx-paginator *igxPaginator *ngIf="childPaging">
328
+
329
+ <!-- Auto migrated template content. Please, check your bindings! -->
330
+
331
+ <igx-paginator-content>
332
+
333
+ <div>
334
+ <button (click)="previous()">PREV</button>
335
+ Current page: {{ hierarchicalGrid.page }}
336
+ <button (click)="next()">NEXT</button>
337
+ </div>
338
+
339
+ </igx-paginator-content>
340
+ </igx-paginator>
341
+
342
+ <igx-column></igx-column>
343
+ </igx-row-island>
344
+ </igx-hierarchical-grid>` . replace ( lineBreaksAndSpaceRegex , '' ) ) ;
345
+ } ) ;
346
+
347
+ it ( 'should define correctly paginator when using the component inside custom template' , async ( ) => {
348
+ appTree . create (
349
+ '/testSrc/appPrefix/component/test.component.html' , `
350
+ <igx-grid #grid1 [data]="data" [paging]="true" [paginationTemplate]="customPager" height="300px" width="300px">
351
+ <igx-column field="Name" header="Athlete"></igx-column>
352
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
353
+ <igx-column field="CountryFlag" header="Country"></igx-column>
354
+ </igx-grid>
355
+ <ng-template #customPager let-api>
356
+ <igx-paginator #paginator [(page)]="grid.page" [totalRecords]="grid.totalRecords" [(perPage)]="grid.perPage"
357
+ [selectOptions]="selectOptions" [displayDensity]="grid.displayDensity">
358
+ </igx-paginator>
359
+ </ng-template>` ) ;
360
+ const tree = await schematicRunner . runSchematicAsync ( migrationName , { } , appTree )
361
+ . toPromise ( ) ;
362
+
363
+ expect ( tree . readContent ( '/testSrc/appPrefix/component/test.component.html' ) . replace ( lineBreaksAndSpaceRegex , '' ) )
364
+ . toEqual ( `
365
+ <igx-grid #grid1 [data]="data" height="300px" width="300px">
366
+ <igx-paginator #paginator [(page)]="grid.page" [totalRecords]="grid.totalRecords" [(perPage)]="grid.perPage"
367
+ [selectOptions]="selectOptions" [displayDensity]="grid.displayDensity">
368
+ </igx-paginator>
369
+ <igx-column field="Name" header="Athlete"></igx-column>
370
+ <igx-column field="TrackProgress" header="Track Progress"></igx-column>
371
+ <igx-column field="CountryFlag" header="Country"></igx-column>
372
+ </igx-grid>
373
+ ` . replace ( lineBreaksAndSpaceRegex , '' ) ) ;
374
+ } ) ;
375
+
197
376
} ) ;
0 commit comments