Skip to content

Commit

Permalink
test: remove usages of deprecated runSchematicAsync function (#48745)
Browse files Browse the repository at this point in the history
Removes our usages of `runSchematicAsync` since it is deprecated.

PR Close #48745
  • Loading branch information
crisbeto authored and AndrewKushnir committed Jan 17, 2023
1 parent a386496 commit 0eec71f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/core/schematics/test/all-migrations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('all migrations', () => {
}

async function runMigration(migrationName: string) {
await runner.runSchematicAsync(migrationName, undefined, tree).toPromise();
await runner.runSchematic(migrationName, undefined, tree);
}

if (!allMigrationSchematics.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Relative link resolution config migration', () => {
}

function runMigration() {
return runner.runSchematicAsync('migration-v15-relative-link-resolution', {}, tree).toPromise();
return runner.runSchematic('migration-v15-relative-link-resolution', {}, tree);
}

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('RouterLinkWithHref migration', () => {
}

function runMigration() {
return runner.runSchematicAsync('migration-v15-router-link-with-href', {}, tree).toPromise();
return runner.runSchematic('migration-v15-router-link-with-href', {}, tree);
}

beforeEach(() => {
Expand Down
17 changes: 8 additions & 9 deletions packages/localize/schematics/ng-add/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('ng-add schematic', () => {
});

it(`should add '@angular/localize' type reference in 'main.ts'`, async () => {
host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
expect(host.readText('main.ts')).toContain(localizeTripleSlashType);
});

Expand All @@ -88,7 +88,7 @@ describe('ng-add schematic', () => {
import { enableProdMode } from '@angular/core';
`;
host.overwrite('main.ts', mainContentInput);
host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
expect(host.readText('main.ts')).toBe(mainContentInput);
});

Expand All @@ -102,7 +102,7 @@ describe('ng-add schematic', () => {

host.create('tsconfig.unknown.json', tsConfig);

host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
const {compilerOptions} = host.readJson('tsconfig.unknown.json') as TsConfig;
const types = compilerOptions?.types;
expect(types).not.toContain('@angular/localize');
Expand All @@ -119,7 +119,7 @@ describe('ng-add schematic', () => {

host.create('tsconfig.app.json', tsConfig);

host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
const {compilerOptions} = host.readJson('tsconfig.app.json') as TsConfig;
const types = compilerOptions?.types;
expect(types).toContain('@angular/localize');
Expand All @@ -137,7 +137,7 @@ describe('ng-add schematic', () => {

host.create('tsconfig.spec.json', tsConfig);

host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
const {compilerOptions} = host.readJson('tsconfig.spec.json') as TsConfig;
const types = compilerOptions?.types;
expect(types).toContain('@angular/localize');
Expand All @@ -152,17 +152,16 @@ describe('ng-add schematic', () => {

host.create('tsconfig.server.json', tsConfig);

host = await schematicRunner.runSchematicAsync('ng-add', defaultOptions, host).toPromise();
host = await schematicRunner.runSchematic('ng-add', defaultOptions, host);
const {compilerOptions} = host.readJson('tsconfig.server.json') as TsConfig;
const types = compilerOptions?.types;
expect(types).toContain('@angular/localize');
expect(types).toHaveSize(1);
});

it('should add package to `dependencies` if `useAtRuntime` is `true`', async () => {
host = await schematicRunner
.runSchematicAsync('ng-add', {...defaultOptions, useAtRuntime: true}, host)
.toPromise();
host =
await schematicRunner.runSchematic('ng-add', {...defaultOptions, useAtRuntime: true}, host);

const {devDependencies, dependencies} = host.readJson('/package.json') as {
devDependencies: {[key: string]: string};
Expand Down

0 comments on commit 0eec71f

Please sign in to comment.