diff --git a/packages/compiler-cli/integrationtest/bazel/injectable_def/app/test/app_spec.ts b/packages/compiler-cli/integrationtest/bazel/injectable_def/app/test/app_spec.ts index ecbbd7fbfc..d94ec80347 100644 --- a/packages/compiler-cli/integrationtest/bazel/injectable_def/app/test/app_spec.ts +++ b/packages/compiler-cli/integrationtest/bazel/injectable_def/app/test/app_spec.ts @@ -9,7 +9,6 @@ import {Component, INJECTOR, Injectable, NgModule} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {renderModuleFactory} from '@angular/platform-server'; -import {fixmeIvy} from '@angular/private/testing'; import {BasicAppModuleNgFactory} from 'app_built/src/basic.ngfactory'; import {DepAppModuleNgFactory} from 'app_built/src/dep.ngfactory'; import {HierarchyAppModuleNgFactory} from 'app_built/src/hierarchy.ngfactory'; diff --git a/packages/core/test/render3/di_spec.ts b/packages/core/test/render3/di_spec.ts index 1cf56f015f..6139a26def 100644 --- a/packages/core/test/render3/di_spec.ts +++ b/packages/core/test/render3/di_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {Attribute, ChangeDetectorRef, ElementRef, Host, Inject, InjectFlags, Injector, Optional, Renderer2, Self, SkipSelf, TemplateRef, ViewContainerRef, createInjector, defineInjectable, defineInjector} from '@angular/core'; +import {Attribute, ChangeDetectorRef, ElementRef, Host, INJECTOR, Inject, InjectFlags, Injector, Optional, Renderer2, Self, SkipSelf, TemplateRef, ViewContainerRef, createInjector, defineInjectable, defineInjector} from '@angular/core'; import {ComponentType, RenderFlags} from '@angular/core/src/render3/interfaces/definition'; import {defineComponent} from '../../src/render3/definition'; @@ -1460,6 +1460,36 @@ describe('di', () => { expect(injectorDir.injector).not.toBe(otherInjectorDir.injector); }); + it('should inject INJECTOR', () => { + let injectorDir !: INJECTORDir; + let divElement !: HTMLElement; + + class INJECTORDir { + constructor(public injector: Injector) {} + + static ngDirectiveDef = defineDirective({ + type: INJECTORDir, + selectors: [['', 'injectorDir', '']], + factory: () => injectorDir = new INJECTORDir(directiveInject(INJECTOR as any)) + }); + } + + + /**
*/ + const App = createComponent('app', (rf: RenderFlags, ctx: any) => { + if (rf & RenderFlags.Create) { + element(0, 'div', ['injectorDir', '']); + } + // testing only + divElement = load(0); + }, 1, 0, [INJECTORDir]); + + const fixture = new ComponentFixture(App); + expect(injectorDir.injector.get(ElementRef).nativeElement).toBe(divElement); + expect(injectorDir.injector.get(Injector).get(ElementRef).nativeElement).toBe(divElement); + expect(injectorDir.injector.get(INJECTOR).get(ElementRef).nativeElement).toBe(divElement); + }); + }); describe('ElementRef', () => {