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:
parent
e498ea9b5a
commit
f3f6a42342
|
@ -1,20 +1,22 @@
|
||||||
|
import { Injector } from '@angular/core';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
import { Duration, Event, EventsComponent } from './events.component';
|
import { Duration, Event, EventsComponent } from './events.component';
|
||||||
import { EventsService } from './events.service';
|
import { EventsService } from './events.service';
|
||||||
import { ReflectiveInjector } from '@angular/core';
|
|
||||||
import { Subject } from 'rxjs';
|
|
||||||
|
|
||||||
describe('EventsComponent', () => {
|
describe('EventsComponent', () => {
|
||||||
let component: EventsComponent;
|
let component: EventsComponent;
|
||||||
let injector: ReflectiveInjector;
|
let injector: Injector;
|
||||||
let eventsService: TestEventsService;
|
let eventsService: TestEventsService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = Injector.create({
|
||||||
EventsComponent,
|
providers: [
|
||||||
{ provide: EventsService, useClass: TestEventsService },
|
{ provide: EventsComponent, deps: [EventsService] } ,
|
||||||
]);
|
{ provide: EventsService, useClass: TestEventsService, deps: [] },
|
||||||
eventsService = injector.get(EventsService) as any;
|
]
|
||||||
component = injector.get(EventsComponent);
|
});
|
||||||
|
eventsService = injector.get(EventsService) as unknown as TestEventsService;
|
||||||
|
component = injector.get(EventsComponent) as unknown as EventsComponent;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have no pastEvents when first created', () => {
|
it('should have no pastEvents when first created', () => {
|
||||||
|
|
Loading…
Reference in New Issue