Skip to content

Commit

Permalink
refactor(@schematics/angular): Use runInInjectionContext shorthand
Browse files Browse the repository at this point in the history
The runInInjectionContext helper was added in angular/angular@6acae14.
This is a shorthand for TestBed.inject(EnvironmentInjector).runInContext.
  • Loading branch information
atscott authored and angular-robot[bot] committed Nov 28, 2022
1 parent 9299dea commit 978274c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/schematics/angular/guard/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Guard Schematic', () => {
const fileString = tree.readContent('/projects/bar/src/app/foo.guard.spec.ts');
expect(fileString).toContain('const executeGuard: CanActivateFn = (...guardParameters) => ');
expect(fileString).toContain(
'TestBed.inject(EnvironmentInjector).runInContext(() => fooGuard(...guardParameters));',
'TestBed.runInInjectionContext(() => fooGuard(...guardParameters));',
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { <%= camelize(name) %>Guard } from './<%= dasherize(name) %>.guard';

describe('<%= camelize(name) %>Guard', () => {
const executeGuard: <%= guardType %> = (...guardParameters) =>
TestBed.inject(EnvironmentInjector).runInContext(() => <%= camelize(name) %>Guard(...guardParameters));
TestBed.runInInjectionContext(() => <%= camelize(name) %>Guard(...guardParameters));

beforeEach(() => {
TestBed.configureTestingModule({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { <%= camelize(name) %>Resolver } from './<%= dasherize(name) %>.resolver

describe('<%= camelize(name) %>Resolver', () => {
const executeResolver: ResolveFn<boolean> = (...resolverParameters) =>
TestBed.inject(EnvironmentInjector).runInContext(() => <%= camelize(name) %>Resolver(...resolverParameters));
TestBed.runInInjectionContext(() => <%= camelize(name) %>Resolver(...resolverParameters));

beforeEach(() => {
TestBed.configureTestingModule({});
Expand Down
2 changes: 1 addition & 1 deletion packages/schematics/angular/resolver/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('resolver Schematic', () => {
'const executeResolver: ResolveFn<boolean> = (...resolverParameters) => ',
);
expect(fileString).toContain(
'TestBed.inject(EnvironmentInjector).runInContext(() => fooResolver(...resolverParameters));',
'TestBed.runInInjectionContext(() => fooResolver(...resolverParameters));',
);
});
});

0 comments on commit 978274c

Please # to comment.