test(docs-infra): replace deprecated `ReflectiveInjector` with `Injector` (#38897)

This commit replaces the old and slow ReflectiveInjector that was
deprecated in v5 with the new Injector.

PR Close #38897
This commit is contained in:
Sonu Kapoor 2020-09-17 18:47:41 -04:00 committed by Misko Hevery
parent e498ea9b5a
commit f3f6a42342
1 changed files with 11 additions and 9 deletions

View File

@ -1,20 +1,22 @@
import { Injector } from '@angular/core';
import { Subject } from 'rxjs';
import { Duration, Event, EventsComponent } from './events.component';
import { EventsService } from './events.service';
import { ReflectiveInjector } from '@angular/core';
import { Subject } from 'rxjs';
describe('EventsComponent', () => {
let component: EventsComponent;
let injector: ReflectiveInjector;
let injector: Injector;
let eventsService: TestEventsService;
beforeEach(() => {
injector = ReflectiveInjector.resolveAndCreate([
EventsComponent,
{ provide: EventsService, useClass: TestEventsService },
]);
eventsService = injector.get(EventsService) as any;
component = injector.get(EventsComponent);
injector = Injector.create({
providers: [
{ provide: EventsComponent, deps: [EventsService] } ,
{ provide: EventsService, useClass: TestEventsService, deps: [] },
]
});
eventsService = injector.get(EventsService) as unknown as TestEventsService;
component = injector.get(EventsComponent) as unknown as EventsComponent;
});
it('should have no pastEvents when first created', () => {