Skip to content

Commit 0af6328

Browse files
committed
test(migrations): use runSchematic which returns promise
1 parent 58a1fe5 commit 0af6328

File tree

28 files changed

+212
-411
lines changed

28 files changed

+212
-411
lines changed

projects/igniteui-angular/migrations/update-10_1_0/index.spec.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ describe('Update 10.1.0', () => {
3232
<igx-icon>arrow_back</igx-icon>
3333
</igx-action-icon>
3434
</igx-navbar>`);
35-
const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree)
36-
.toPromise();
35+
const tree = await schematicRunner.runSchematic('migration-16', {}, appTree);
3736

3837
expect(tree.readContent('/testSrc/appPrefix/component/custom.component.html'))
3938
.toEqual(
@@ -51,7 +50,7 @@ describe('Update 10.1.0', () => {
5150
@ViewChild(IgxActionIconDirective, { read: IgxActionIconDirective })
5251
private actionIcon: IgxActionIconDirective; }`);
5352

54-
const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree).toPromise();
53+
const tree = await schematicRunner.runSchematic('migration-16', {}, appTree);
5554

5655
expect(tree.readContent('/testSrc/appPrefix/component/custom.component.ts'))
5756
.toEqual(
@@ -96,7 +95,7 @@ describe('Update 10.1.0', () => {
9695
'/testSrc/appPrefix/component/drop.component.ts',
9796
origFileContent);
9897

99-
const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree).toPromise();
98+
const tree = await schematicRunner.runSchematic('migration-16', {}, appTree);
10099
expect(tree.readContent('/testSrc/appPrefix/component/drop.component.ts'))
101100
.toEqual(expectedFileContent);
102101
});
@@ -107,8 +106,7 @@ describe('Update 10.1.0', () => {
107106
'<igx-tree-grid (onDataPreLoad)="handleEvent($event)"></igx-tree-grid>'
108107
);
109108

110-
const tree = await schematicRunner.runSchematicAsync('migration-16', {}, appTree)
111-
.toPromise();
109+
const tree = await schematicRunner.runSchematic('migration-16', {}, appTree);
112110

113111
expect(tree.readContent('/testSrc/appPrefix/component/tree-grid.component.html'))
114112
.toEqual('<igx-tree-grid (onScroll)="handleEvent($event)"></igx-tree-grid>');

projects/igniteui-angular/migrations/update-10_2_0/index.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ describe('Update 10.2.0', () => {
3939
);
4040

4141
const tree = await schematicRunner
42-
.runSchematicAsync('migration-17', {}, appTree)
43-
.toPromise();
42+
.runSchematic('migration-17', {}, appTree);
4443
expect(
4544
tree.readContent('/testSrc/appPrefix/component/test.component.html')
4645
// eslint-disable-next-line max-len
@@ -74,8 +73,7 @@ export class ExpansionTestComponent {
7473
}`
7574
);
7675
const tree = await schematicRunner
77-
.runSchematicAsync('migration-17', {}, appTree)
78-
.toPromise();
76+
.runSchematic('migration-17', {}, appTree);
7977
const expectedContent = `import { Component, ViewChild } from '@angular/core';
8078
import { IExpansionPanelEventArgs, IgxExpansionPanelComponent } from 'igniteui-angular';
8179

projects/igniteui-angular/migrations/update-11_0_0/index.spec.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ describe('Update to 11.0.0', () => {
7474
appTree.create(makeTemplate('toolbar'), basicTemplate);
7575

7676
const tree = await runner
77-
.runSchematicAsync(migrationName, {}, appTree)
78-
.toPromise();
77+
.runSchematic(migrationName, {}, appTree);
7978
expect(
8079
tree.readContent(makeTemplate('toolbar'))
8180
).toEqual(`<igx-grid>\n<igx-grid-toolbar></igx-grid-toolbar>\nLook, some content</igx-grid>`);
@@ -85,8 +84,7 @@ describe('Update to 11.0.0', () => {
8584
appTree.create(makeTemplate('toolbar'), bindingTemplate);
8685

8786
const tree = await runner
88-
.runSchematicAsync(migrationName, {}, appTree)
89-
.toPromise();
87+
.runSchematic(migrationName, {}, appTree);
9088
expect(
9189
tree.readContent(makeTemplate('toolbar'))
9290
).toEqual(`<igx-grid>\n<igx-grid-toolbar *ngIf="condition"></igx-grid-toolbar>\n</igx-grid>`);
@@ -96,8 +94,7 @@ describe('Update to 11.0.0', () => {
9694
appTree.create(makeTemplate('toolbar'), directiveTemplate);
9795

9896
const tree = await runner
99-
.runSchematicAsync(migrationName, {}, appTree)
100-
.toPromise();
97+
.runSchematic(migrationName, {}, appTree);
10198
expect(
10299
tree.readContent(makeTemplate('toolbar')).replace(stripWhitespaceRe, '')
103100
).toEqual(`
@@ -119,8 +116,7 @@ describe('Update to 11.0.0', () => {
119116
appTree.create(makeTemplate('toolbar'), hierachicalBase);
120117

121118
const tree = await runner
122-
.runSchematicAsync(migrationName, {}, appTree)
123-
.toPromise();
119+
.runSchematic(migrationName, {}, appTree);
124120
expect(
125121
tree.readContent(makeTemplate('toolbar')).replace(stripWhitespaceRe, '')
126122
).toEqual(`
@@ -139,8 +135,7 @@ describe('Update to 11.0.0', () => {
139135
appTree.create(makeTemplate('toolbar'), hierachicalBaseTemplate);
140136

141137
const tree = await runner
142-
.runSchematicAsync(migrationName, {}, appTree)
143-
.toPromise();
138+
.runSchematic(migrationName, {}, appTree);
144139
expect(
145140
tree.readContent(makeTemplate('toolbar')).replace(stripWhitespaceRe, '')
146141
).toEqual(`

projects/igniteui-angular/migrations/update-11_1_0/index.spec.ts

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ describe('Update to 11.1.0', () => {
3434
);
3535

3636
const tree = await runner
37-
.runSchematicAsync('migration-19', {}, appTree)
38-
.toPromise();
37+
.runSchematic('migration-19', {}, appTree);
3938

4039
expect(
4140
tree.readContent('/testSrc/appPrefix/component/icon.component.html')
@@ -49,8 +48,7 @@ describe('Update to 11.1.0', () => {
4948
);
5049

5150
const tree = await runner
52-
.runSchematicAsync('migration-19', {}, appTree)
53-
.toPromise();
51+
.runSchematic('migration-19', {}, appTree);
5452

5553
expect(
5654
tree.readContent('/testSrc/appPrefix/component/icon.component.html')
@@ -87,8 +85,7 @@ export class IconTestComponent {
8785
`);
8886

8987
const tree = await runner
90-
.runSchematicAsync('migration-19', {}, appTree)
91-
.toPromise();
88+
.runSchematic('migration-19', {}, appTree);
9289

9390
const expectedContent = `import { Component, ViewChild } from '@angular/core';
9491
import { IgxIconModule, IgxIconComponent } from 'igniteui-angular';
@@ -152,8 +149,7 @@ export class IconTestComponent {
152149
`);
153150

154151
const tree = await runner
155-
.runSchematicAsync('migration-19', {}, appTree)
156-
.toPromise();
152+
.runSchematic('migration-19', {}, appTree);
157153

158154
const expectedContent = `import { Component } from '@angular/core';
159155
import { IgxIconService } from 'igniteui-angular';
@@ -208,8 +204,7 @@ export class IconTestComponent {
208204
</igx-chip>
209205
</igx-chips-area>`
210206
);
211-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
212-
.toPromise();
207+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
213208

214209
expect(tree.readContent('/testSrc/appPrefix/component/chips.component.html'))
215210
.toEqual(`<igx-chips-area #chipsAreaTo class="chipAreaTo"
@@ -241,8 +236,7 @@ export class IconTestComponent {
241236
);
242237

243238
const tree = await runner
244-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
245-
.toPromise();
239+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
246240
expect(
247241
tree.readContent('/testSrc/appPrefix/component/tabs.component.html')
248242
).toEqual(`<igx-tabs (tabItemSelected)="tabSelected()"></igx-tabs>`);
@@ -255,8 +249,7 @@ export class IconTestComponent {
255249
);
256250

257251
const tree = await runner
258-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
259-
.toPromise();
252+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
260253
expect(
261254
tree.readContent('/testSrc/appPrefix/component/tabs.component.html')
262255
).toEqual(`<igx-tabs (tabItemDeselected)="tabDeselected()"></igx-tabs>`);
@@ -269,8 +262,7 @@ export class IconTestComponent {
269262
);
270263

271264
const tree = await runner
272-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
273-
.toPromise();
265+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
274266
expect(
275267
tree.readContent('/testSrc/appPrefix/component/list.component.html')
276268
).toEqual(`<igx-list [allowLeftPanning]="true" (leftPan)="leftPanPerformed($event)">`);
@@ -283,8 +275,7 @@ export class IconTestComponent {
283275
);
284276

285277
const tree = await runner
286-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
287-
.toPromise();
278+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
288279
expect(
289280
tree.readContent('/testSrc/appPrefix/component/list.component.html')
290281
).toEqual(`<igx-list [allowRightPanning]="true" (rightPan)="rightPanPerformed($event)">`);
@@ -297,8 +288,7 @@ export class IconTestComponent {
297288
);
298289

299290
const tree = await runner
300-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
301-
.toPromise();
291+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
302292
expect(
303293
tree.readContent('/testSrc/appPrefix/component/list.component.html')
304294
).toEqual(`<igx-list (panStateChange)="panStateChange($event)"></igx-list>`);
@@ -311,8 +301,7 @@ export class IconTestComponent {
311301
);
312302

313303
const tree = await runner
314-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
315-
.toPromise();
304+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
316305
expect(
317306
tree.readContent('/testSrc/appPrefix/component/list.component.html')
318307
).toEqual(`<igx-list (itemClicked)="onItemClicked($event)"></igx-list>`);
@@ -325,8 +314,7 @@ export class IconTestComponent {
325314
);
326315

327316
const tree = await runner
328-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
329-
.toPromise();
317+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
330318
expect(
331319
tree.readContent('/testSrc/appPrefix/component/navbar.component.html')
332320
).toEqual(`<igx-navbar (action)="actionExc($event)" title="Sample App" actionButtonIcon="menu"></igx-navbar>`);
@@ -358,8 +346,7 @@ export class ExcelExportComponent {
358346
`);
359347

360348
const tree = await runner
361-
.runSchematicAsync('migration-19', {}, appTree)
362-
.toPromise();
349+
.runSchematic('migration-19', {}, appTree);
363350

364351
const expectedContent =
365352
`import { Component } from '@angular/core';
@@ -416,8 +403,7 @@ export class CsvExportComponent {
416403
`);
417404

418405
const tree = await runner
419-
.runSchematicAsync('migration-19', {}, appTree)
420-
.toPromise();
406+
.runSchematic('migration-19', {}, appTree);
421407

422408
const expectedContent =
423409
`import { Component } from '@angular/core';
@@ -457,7 +443,7 @@ export class CsvExportComponent {
457443
</igx-buttongroup>`
458444
);
459445

460-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
446+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
461447

462448
expect(tree.readContent('/testSrc/appPrefix/component/buttongroup.component.html')).toEqual(
463449
`<igx-buttongroup
@@ -474,7 +460,7 @@ export class CsvExportComponent {
474460
`<igx-snackbar (onAction)="someHandler($event)"></igx-snackbar>`
475461
);
476462

477-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
463+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
478464

479465
expect(tree.readContent('/testSrc/appPrefix/component/snackbar.component.html')).toEqual(
480466
`<igx-snackbar (clicked)="someHandler($event)"></igx-snackbar>`
@@ -493,7 +479,7 @@ export class CsvExportComponent {
493479
</igx-toast>`
494480
);
495481

496-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
482+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
497483

498484
expect(tree.readContent('/testSrc/appPrefix/component/toast.component.html')).toEqual(
499485
`<igx-toast
@@ -519,8 +505,7 @@ export class CsvExportComponent {
519505
);
520506

521507
const tree = await runner
522-
.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree)
523-
.toPromise();
508+
.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
524509
expect(
525510
tree.readContent('/testSrc/appPrefix/component/tooltip.component.html')
526511
).toEqual(
@@ -544,7 +529,7 @@ export class CsvExportComponent {
544529
></igx-calendar>`
545530
);
546531

547-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
532+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
548533

549534
expect(tree.readContent('/testSrc/appPrefix/component/calendar.component.html')).toEqual(
550535
`<igx-calendar
@@ -566,7 +551,7 @@ export class CsvExportComponent {
566551
></igx-years-view>`
567552
);
568553

569-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
554+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
570555

571556
expect(tree.readContent('/testSrc/appPrefix/component/yearsview.component.html')).toEqual(
572557
`<igx-years-view
@@ -585,7 +570,7 @@ export class CsvExportComponent {
585570
></igx-days-view>`
586571
);
587572

588-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
573+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
589574

590575
expect(tree.readContent('/testSrc/appPrefix/component/daysview.component.html')).toEqual(
591576
`<igx-days-view
@@ -604,7 +589,7 @@ export class CsvExportComponent {
604589
></igx-months-view>`
605590
);
606591

607-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
592+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
608593

609594
expect(tree.readContent('/testSrc/appPrefix/component/monthsview.component.html')).toEqual(
610595
`<igx-months-view
@@ -622,7 +607,7 @@ export class CsvExportComponent {
622607
></igx-month-picker>`
623608
);
624609

625-
const tree = await runner.runSchematicAsync(migrationName, { shouldInvokeLS: false }, appTree).toPromise();
610+
const tree = await runner.runSchematic(migrationName, { shouldInvokeLS: false }, appTree);
626611

627612
expect(tree.readContent('/testSrc/appPrefix/component/monthpicker.component.html')).toEqual(
628613
`<igx-month-picker
@@ -658,8 +643,7 @@ export class ExcelExportComponent {
658643
`);
659644

660645
const tree = await runner
661-
.runSchematicAsync('migration-19', {}, appTree)
662-
.toPromise();
646+
.runSchematic('migration-19', {}, appTree);
663647

664648
const expectedContent =
665649
`import { Component } from '@angular/core';
@@ -718,8 +702,7 @@ export class CsvExportComponent {
718702
`);
719703

720704
const tree = await runner
721-
.runSchematicAsync('migration-19', {}, appTree)
722-
.toPromise();
705+
.runSchematic('migration-19', {}, appTree);
723706

724707
const expectedContent =
725708
`import { Component } from '@angular/core';
@@ -770,8 +753,7 @@ export class PagingComponent {
770753
`);
771754

772755
const tree = await runner
773-
.runSchematicAsync('migration-19', {}, appTree)
774-
.toPromise();
756+
.runSchematic('migration-19', {}, appTree);
775757

776758
const expectedContent =
777759
`import { Component } from '@angular/core';

0 commit comments

Comments
 (0)