test(core): add JIRA references for root-casuse ivy TestBed failures (#27196)

PR Close #27196
This commit is contained in:
Pawel Kozlowski 2018-11-20 17:00:41 +01:00 committed by Miško Hevery
parent a72250bace
commit d666370e16
9 changed files with 2416 additions and 2214 deletions

View File

@ -15,10 +15,10 @@ import {fixmeIvy} from '@angular/private/testing';
{ {
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
} }
} }
@ -71,8 +71,11 @@ function declareTests(config?: {useJit: boolean}) {
expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp); expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
}); });
it('should not be able to get components from a parent component (content hierarchy)', () => { fixmeIvy('unknown') &&
TestBed.overrideComponent(MainComp, {set: {template: '<child><nested></nested></child>'}}); it('should not be able to get components from a parent component (content hierarchy)',
() => {
TestBed.overrideComponent(
MainComp, {set: {template: '<child><nested></nested></child>'}});
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}}); TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
const compFixture = TestBed.createComponent(MainComp); const compFixture = TestBed.createComponent(MainComp);

View File

@ -7,7 +7,6 @@
*/ */
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {CompilerConfig} from '@angular/compiler';
import {Compiler, ComponentFactory, ComponentRef, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, SkipSelf, ViewRef, ɵivyEnabled as ivyEnabled} from '@angular/core'; import {Compiler, ComponentFactory, ComponentRef, ErrorHandler, EventEmitter, Host, Inject, Injectable, InjectionToken, Injector, NO_ERRORS_SCHEMA, NgModule, NgModuleRef, OnDestroy, SkipSelf, ViewRef, ɵivyEnabled as ivyEnabled} from '@angular/core';
import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection'; import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection';
import {getDebugContext} from '@angular/core/src/errors'; import {getDebugContext} from '@angular/core/src/errors';
@ -31,10 +30,10 @@ const ANCHOR_ELEMENT = new InjectionToken('AnchorElement');
{ {
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
} }
} }
@ -213,7 +212,7 @@ function declareTests(config?: {useJit: boolean}) {
.toEqual('Some other <div>HTML</div>'); .toEqual('Some other <div>HTML</div>');
}); });
it('should consume binding to className using class alias', () => { fixmeIvy('unknown') && it('should consume binding to className using class alias', () => {
TestBed.configureTestingModule({declarations: [MyComp]}); TestBed.configureTestingModule({declarations: [MyComp]});
const template = '<div class="initial" [class]="ctxProp"></div>'; const template = '<div class="initial" [class]="ctxProp"></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -228,6 +227,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(nativeEl).not.toHaveCssClass('initial'); expect(nativeEl).not.toHaveCssClass('initial');
}); });
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work') &&
it('should consume binding to htmlFor using for alias', () => { it('should consume binding to htmlFor using for alias', () => {
const template = '<label [for]="ctxProp"></label>'; const template = '<label [for]="ctxProp"></label>';
const fixture = TestBed.configureTestingModule({declarations: [MyComp]}) const fixture = TestBed.configureTestingModule({declarations: [MyComp]})
@ -241,7 +241,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().getProperty(nativeEl, 'htmlFor')).toBe('foo'); expect(getDOM().getProperty(nativeEl, 'htmlFor')).toBe('foo');
}); });
it('should consume directive watch expression change.', () => { fixmeIvy('unknown') && it('should consume directive watch expression change.', () => {
TestBed.configureTestingModule({declarations: [MyComp, MyDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
const template = '<span>' + const template = '<span>' +
'<div my-dir [elprop]="ctxProp"></div>' + '<div my-dir [elprop]="ctxProp"></div>' +
@ -265,7 +265,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('pipes', () => { describe('pipes', () => {
it('should support pipes in bindings', () => { fixmeIvy('unknown') && it('should support pipes in bindings', () => {
TestBed.configureTestingModule({declarations: [MyComp, MyDir, DoublePipe]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir, DoublePipe]});
const template = '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>'; const template = '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -291,7 +291,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
// GH issue 328 - https://github.com/angular/angular/issues/328 // GH issue 328 - https://github.com/angular/angular/issues/328
it('should support different directive types on a single node', () => { fixmeIvy('unknown') && it('should support different directive types on a single node', () => {
TestBed.configureTestingModule({declarations: [MyComp, ChildComp, MyDir]}); TestBed.configureTestingModule({declarations: [MyComp, ChildComp, MyDir]});
const template = '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>'; const template = '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -350,6 +350,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(tc.injector.get(EventDir)).not.toBeNull(); expect(tc.injector.get(EventDir)).not.toBeNull();
}); });
fixmeIvy('unknown') &&
it('should display correct error message for uninitialized @Output', () => { it('should display correct error message for uninitialized @Output', () => {
@Component({selector: 'my-uninitialized-output', template: '<p>It works!</p>'}) @Component({selector: 'my-uninitialized-output', template: '<p>It works!</p>'})
class UninitializedOutputComp { class UninitializedOutputComp {
@ -362,7 +363,8 @@ function declareTests(config?: {useJit: boolean}) {
TestBed.configureTestingModule({declarations: [MyComp, UninitializedOutputComp]}); TestBed.configureTestingModule({declarations: [MyComp, UninitializedOutputComp]});
expect(() => TestBed.createComponent(MyComp)) expect(() => TestBed.createComponent(MyComp))
.toThrowError('@Output customEvent not initialized in \'UninitializedOutputComp\'.'); .toThrowError(
'@Output customEvent not initialized in \'UninitializedOutputComp\'.');
}); });
it('should read directives metadata from their binding token', () => { it('should read directives metadata from their binding token', () => {
@ -372,6 +374,7 @@ function declareTests(config?: {useJit: boolean}) {
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
}); });
fixmeIvy('unknown') &&
it('should support template directives via `<ng-template>` elements.', () => { it('should support template directives via `<ng-template>` elements.', () => {
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]}); TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
const template = const template =
@ -399,6 +402,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(fixture.nativeElement).toHaveText('baz'); expect(fixture.nativeElement).toHaveText('baz');
}); });
fixmeIvy('unknown') &&
it('should not detach views in ViewContainers when the parent view is destroyed.', () => { it('should not detach views in ViewContainers when the parent view is destroyed.', () => {
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]}); TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
const template = const template =
@ -473,6 +477,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBeAnInstanceOf(ExportDir); .toBeAnInstanceOf(ExportDir);
}); });
fixmeIvy('unknown') &&
it('should assign a directive to a ref when it has multiple exportAs names', () => { it('should assign a directive to a ref when it has multiple exportAs names', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MyComp, DirectiveWithMultipleExportAsNames]}); {declarations: [MyComp, DirectiveWithMultipleExportAsNames]});
@ -537,6 +542,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(value.tagName.toLowerCase()).toEqual('div'); expect(value.tagName.toLowerCase()).toEqual('div');
}); });
fixmeIvy('unknown') &&
it('should assign the TemplateRef to a user-defined variable', () => { it('should assign the TemplateRef to a user-defined variable', () => {
const fixture = const fixture =
TestBed.configureTestingModule({declarations: [MyComp]}) TestBed.configureTestingModule({declarations: [MyComp]})
@ -560,7 +566,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('variables', () => { describe('variables', () => {
it('should allow to use variables in a for loop', () => { fixmeIvy('unknown') && it('should allow to use variables in a for loop', () => {
const template = const template =
'<ng-template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</ng-template>'; '<ng-template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</ng-template>';
@ -577,6 +583,7 @@ function declareTests(config?: {useJit: boolean}) {
describe('OnPush components', () => { describe('OnPush components', () => {
fixmeIvy('unknown') &&
it('should use ChangeDetectorRef to manually request a check', () => { it('should use ChangeDetectorRef to manually request a check', () => {
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithRef]]]}); TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithRef]]]});
const template = '<push-cmp-with-ref #cmp></push-cmp-with-ref>'; const template = '<push-cmp-with-ref #cmp></push-cmp-with-ref>';
@ -597,7 +604,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(cmp.numberOfChecks).toEqual(2); expect(cmp.numberOfChecks).toEqual(2);
}); });
it('should be checked when its bindings got updated', () => { fixmeIvy('unknown') && it('should be checked when its bindings got updated', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]}); {declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>'; const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
@ -616,9 +623,11 @@ function declareTests(config?: {useJit: boolean}) {
}); });
if (getDOM().supportsDOMEvents()) { if (getDOM().supportsDOMEvents()) {
fixmeIvy('unknown') &&
it('should allow to destroy a component from within a host event handler', it('should allow to destroy a component from within a host event handler',
fakeAsync(() => { fakeAsync(() => {
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]}); TestBed.configureTestingModule(
{declarations: [MyComp, [[PushCmpWithHostEvent]]]});
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>'; const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
@ -634,7 +643,7 @@ function declareTests(config?: {useJit: boolean}) {
})); }));
} }
it('should be checked when an event is fired', () => { fixmeIvy('unknown') && it('should be checked when an event is fired', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]}); {declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>'; const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
@ -758,6 +767,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective); expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective);
}); });
fixmeIvy('unknown') &&
it('should support events via EventEmitter on regular elements', async(() => { it('should support events via EventEmitter on regular elements', async(() => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}); {declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]});
@ -788,11 +798,14 @@ function declareTests(config?: {useJit: boolean}) {
emitter.fireEvent('fired !'); emitter.fireEvent('fired !');
})); }));
fixmeIvy(
'FW-665: Discovery util fails with Unable to find the given context data for the given target') &&
it('should support events via EventEmitter on template elements', async(() => { it('should support events via EventEmitter on template elements', async(() => {
const fixture = const fixture =
TestBed TestBed
.configureTestingModule( .configureTestingModule({
{declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}) declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]
})
.overrideComponent(MyComp, { .overrideComponent(MyComp, {
set: { set: {
template: template:
@ -839,7 +852,7 @@ function declareTests(config?: {useJit: boolean}) {
dir.triggerChange('two'); dir.triggerChange('two');
})); }));
it('should support render events', () => { fixmeIvy('unknown') && it('should support render events', () => {
TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]}); TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]});
const template = '<div listener></div>'; const template = '<div listener></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -860,7 +873,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(listener.eventTypes).toEqual([]); expect(listener.eventTypes).toEqual([]);
}); });
it('should support render global events', () => { fixmeIvy('unknown') && it('should support render global events', () => {
TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]}); TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]});
const template = '<div listener></div>'; const template = '<div listener></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -907,7 +920,7 @@ function declareTests(config?: {useJit: boolean}) {
.toEqual('button'); .toEqual('button');
}); });
it('should support updating host element via hostProperties', () => { fixmeIvy('unknown') && it('should support updating host element via hostProperties', () => {
TestBed.configureTestingModule({declarations: [MyComp, DirectiveUpdatingHostProperties]}); TestBed.configureTestingModule({declarations: [MyComp, DirectiveUpdatingHostProperties]});
const template = '<div update-host-properties></div>'; const template = '<div update-host-properties></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -942,7 +955,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(tc.properties['title']).toBe(undefined); expect(tc.properties['title']).toBe(undefined);
}); });
it('should not allow pipes in hostProperties', () => { fixmeIvy('unknown') && it('should not allow pipes in hostProperties', () => {
@Directive({selector: '[host-properties]', host: {'[id]': 'id | uppercase'}}) @Directive({selector: '[host-properties]', host: {'[id]': 'id | uppercase'}})
class DirectiveWithHostProps { class DirectiveWithHostProps {
} }
@ -977,7 +990,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(dir.receivedArgs).toEqual(['one', undefined]); expect(dir.receivedArgs).toEqual(['one', undefined]);
}); });
it('should not allow pipes in hostListeners', () => { fixmeIvy('unknown') && it('should not allow pipes in hostListeners', () => {
@Directive({selector: '[host-listener]', host: {'(click)': 'doIt() | somePipe'}}) @Directive({selector: '[host-listener]', host: {'(click)': 'doIt() | somePipe'}})
class DirectiveWithHostListener { class DirectiveWithHostListener {
} }
@ -1013,9 +1026,11 @@ function declareTests(config?: {useJit: boolean}) {
}); });
} }
fixmeIvy('unknown') &&
it('should support render global events from multiple directives', () => { it('should support render global events from multiple directives', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule({
{declarations: [MyComp, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]}); declarations: [MyComp, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
});
const template = '<div *ngIf="ctxBoolProp" listener listenerother></div>'; const template = '<div *ngIf="ctxBoolProp" listener listenerother></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
@ -1092,6 +1107,7 @@ function declareTests(config?: {useJit: boolean}) {
.toHaveText('dynamic greet'); .toHaveText('dynamic greet');
})); }));
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create a component that has been freshly compiled', () => { it('should create a component that has been freshly compiled', () => {
@Component({template: ''}) @Component({template: ''})
class RootComp { class RootComp {
@ -1117,8 +1133,8 @@ function declareTests(config?: {useJit: boolean}) {
class MyModule { class MyModule {
} }
const compFixture = const compFixture = TestBed.configureTestingModule({imports: [RootModule]})
TestBed.configureTestingModule({imports: [RootModule]}).createComponent(RootComp); .createComponent(RootComp);
const compiler = <Compiler>TestBed.get(Compiler); const compiler = <Compiler>TestBed.get(Compiler);
const myCompFactory = const myCompFactory =
<ComponentFactory<MyComp>>compiler.compileModuleAndAllComponentsSync(MyModule) <ComponentFactory<MyComp>>compiler.compileModuleAndAllComponentsSync(MyModule)
@ -1131,6 +1147,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(compRef.instance.someToken).toBe('someRootValue'); expect(compRef.instance.someToken).toBe('someRootValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create a component with the passed NgModuleRef', () => { it('should create a component with the passed NgModuleRef', () => {
@Component({template: ''}) @Component({template: ''})
class RootComp { class RootComp {
@ -1154,11 +1171,13 @@ function declareTests(config?: {useJit: boolean}) {
class MyModule { class MyModule {
} }
const compFixture = const compFixture = TestBed.configureTestingModule({imports: [RootModule]})
TestBed.configureTestingModule({imports: [RootModule]}).createComponent(RootComp); .createComponent(RootComp);
const compiler = <Compiler>TestBed.get(Compiler); const compiler = <Compiler>TestBed.get(Compiler);
const myModule = compiler.compileModuleSync(MyModule).create(TestBed.get(NgModuleRef)); const myModule =
const myCompFactory = (<ComponentFactoryResolver>TestBed.get(ComponentFactoryResolver)) compiler.compileModuleSync(MyModule).create(TestBed.get(NgModuleRef));
const myCompFactory =
(<ComponentFactoryResolver>TestBed.get(ComponentFactoryResolver))
.resolveComponentFactory(MyComp); .resolveComponentFactory(MyComp);
// Note: MyComp was declared as entryComponent in the RootModule, // Note: MyComp was declared as entryComponent in the RootModule,
@ -1169,6 +1188,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(compRef.instance.someToken).toBe('someValue'); expect(compRef.instance.someToken).toBe('someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create a component with the NgModuleRef of the ComponentFactoryResolver', it('should create a component with the NgModuleRef of the ComponentFactoryResolver',
() => { () => {
@Component({template: ''}) @Component({template: ''})
@ -1213,6 +1233,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('.insert', () => { describe('.insert', () => {
fixmeIvy('unknown') &&
it('should throw with destroyed views', async(() => { it('should throw with destroyed views', async(() => {
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]}) const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp); .createComponent(MyComp);
@ -1229,6 +1250,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('.move', () => { describe('.move', () => {
fixmeIvy('unknown') &&
it('should throw with destroyed views', async(() => { it('should throw with destroyed views', async(() => {
const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]}) const fixture = TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]})
.createComponent(MyComp); .createComponent(MyComp);
@ -1246,7 +1268,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
it('should support static attributes', () => { fixmeIvy('unknown') && it('should support static attributes', () => {
TestBed.configureTestingModule({declarations: [MyComp, NeedsAttribute]}); TestBed.configureTestingModule({declarations: [MyComp, NeedsAttribute]});
const template = '<input static type="text" title>'; const template = '<input static type="text" title>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -1259,7 +1281,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(needsAttribute.fooAttribute).toBeNull(); expect(needsAttribute.fooAttribute).toBeNull();
}); });
it('should support custom interpolation', () => { fixmeIvy('unknown') && it('should support custom interpolation', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
MyComp, ComponentWithCustomInterpolationA, ComponentWithCustomInterpolationB, MyComp, ComponentWithCustomInterpolationA, ComponentWithCustomInterpolationB,
@ -1300,7 +1322,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(comp.injectable).toBeAnInstanceOf(InjectableService); expect(comp.injectable).toBeAnInstanceOf(InjectableService);
}); });
it('should support viewProviders', () => { fixmeIvy('unknown') && it('should support viewProviders', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [MyComp, DirectiveProvidingInjectableInView, DirectiveConsumingInjectable], declarations: [MyComp, DirectiveProvidingInjectableInView, DirectiveConsumingInjectable],
schemas: [NO_ERRORS_SCHEMA], schemas: [NO_ERRORS_SCHEMA],
@ -1412,6 +1434,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().querySelectorAll(fixture.nativeElement, 'script').length).toEqual(0); expect(getDOM().querySelectorAll(fixture.nativeElement, 'script').length).toEqual(0);
}); });
fixmeIvy('FW-662: Components without selector are not supported') &&
it('should throw when using directives without selector', () => { it('should throw when using directives without selector', () => {
@Directive({}) @Directive({})
class SomeDirective { class SomeDirective {
@ -1423,9 +1446,11 @@ function declareTests(config?: {useJit: boolean}) {
TestBed.configureTestingModule({declarations: [MyComp, SomeDirective, SomeComponent]}); TestBed.configureTestingModule({declarations: [MyComp, SomeDirective, SomeComponent]});
expect(() => TestBed.createComponent(MyComp)) expect(() => TestBed.createComponent(MyComp))
.toThrowError(`Directive ${stringify(SomeDirective)} has no selector, please add it!`); .toThrowError(
`Directive ${stringify(SomeDirective)} has no selector, please add it!`);
}); });
fixmeIvy('FW-662: Components without selector are not supported') &&
it('should use a default element name for components without selectors', () => { it('should use a default element name for components without selectors', () => {
let noSelectorComponentFactory: ComponentFactory<SomeComponent> = undefined !; let noSelectorComponentFactory: ComponentFactory<SomeComponent> = undefined !;
@ -1433,7 +1458,8 @@ function declareTests(config?: {useJit: boolean}) {
class NoSelectorComponent { class NoSelectorComponent {
} }
@Component({selector: 'some-comp', template: '', entryComponents: [NoSelectorComponent]}) @Component(
{selector: 'some-comp', template: '', entryComponents: [NoSelectorComponent]})
class SomeComponent { class SomeComponent {
constructor(componentFactoryResolver: ComponentFactoryResolver) { constructor(componentFactoryResolver: ComponentFactoryResolver) {
// grab its own component factory // grab its own component factory
@ -1449,23 +1475,26 @@ function declareTests(config?: {useJit: boolean}) {
expect(noSelectorComponentFactory.selector).toBe('ng-component'); expect(noSelectorComponentFactory.selector).toBe('ng-component');
expect( expect(getDOM()
getDOM() .nodeName(
.nodeName(noSelectorComponentFactory.create(Injector.NULL).location.nativeElement) noSelectorComponentFactory.create(Injector.NULL).location.nativeElement)
.toLowerCase()) .toLowerCase())
.toEqual('ng-component'); .toEqual('ng-component');
}); });
}); });
describe('error handling', () => { describe('error handling', () => {
fixmeIvy('unknown') &&
it('should report a meaningful error when a directive is missing annotation', () => { it('should report a meaningful error when a directive is missing annotation', () => {
TestBed.configureTestingModule({declarations: [MyComp, SomeDirectiveMissingAnnotation]}); TestBed.configureTestingModule(
{declarations: [MyComp, SomeDirectiveMissingAnnotation]});
expect(() => TestBed.createComponent(MyComp)) expect(() => TestBed.createComponent(MyComp))
.toThrowError( .toThrowError(
`Unexpected value '${stringify(SomeDirectiveMissingAnnotation)}' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.`); `Unexpected value '${stringify(SomeDirectiveMissingAnnotation)}' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.`);
}); });
fixmeIvy('unknown') &&
it('should report a meaningful error when a component is missing view annotation', () => { it('should report a meaningful error when a component is missing view annotation', () => {
TestBed.configureTestingModule({declarations: [MyComp, ComponentWithoutView]}); TestBed.configureTestingModule({declarations: [MyComp, ComponentWithoutView]});
try { try {
@ -1477,6 +1506,7 @@ function declareTests(config?: {useJit: boolean}) {
} }
}); });
fixmeIvy('unknown') &&
it('should provide an error context when an error happens in DI', () => { it('should provide an error context when an error happens in DI', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [MyComp, DirectiveThrowingAnError], declarations: [MyComp, DirectiveThrowingAnError],
@ -1495,6 +1525,7 @@ function declareTests(config?: {useJit: boolean}) {
} }
}); });
fixmeIvy('unknown') &&
it('should provide an error context when an error happens in change detection', () => { it('should provide an error context when an error happens in change detection', () => {
TestBed.configureTestingModule({declarations: [MyComp, DirectiveThrowingAnError]}); TestBed.configureTestingModule({declarations: [MyComp, DirectiveThrowingAnError]});
const template = `<input [value]="one.two.three" #local>`; const template = `<input [value]="one.two.three" #local>`;
@ -1513,6 +1544,7 @@ function declareTests(config?: {useJit: boolean}) {
} }
}); });
fixmeIvy('unknown') &&
it('should provide an error context when an error happens in change detection (text node)', it('should provide an error context when an error happens in change detection (text node)',
() => { () => {
TestBed.configureTestingModule({declarations: [MyComp]}); TestBed.configureTestingModule({declarations: [MyComp]});
@ -1591,7 +1623,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('Property bindings', () => { describe('Property bindings', () => {
it('should throw on bindings to unknown properties', () => { fixmeIvy('unknown') && it('should throw on bindings to unknown properties', () => {
TestBed.configureTestingModule({declarations: [MyComp]}); TestBed.configureTestingModule({declarations: [MyComp]});
const template = '<div unknown="{{ctxProp}}"></div>'; const template = '<div unknown="{{ctxProp}}"></div>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -1625,8 +1657,10 @@ function declareTests(config?: {useJit: boolean}) {
expect(el.title).toBeFalsy(); expect(el.title).toBeFalsy();
}); });
fixmeIvy('unknown') &&
it('should work when a directive uses hostProperty to update the DOM element', () => { it('should work when a directive uses hostProperty to update the DOM element', () => {
TestBed.configureTestingModule({declarations: [MyComp, DirectiveWithTitleAndHostProperty]}); TestBed.configureTestingModule(
{declarations: [MyComp, DirectiveWithTitleAndHostProperty]});
const template = '<span [title]="ctxProp"></span>'; const template = '<span [title]="ctxProp"></span>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
@ -1640,6 +1674,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('logging property updates', () => { describe('logging property updates', () => {
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
it('should reflect property values as attributes', () => { it('should reflect property values as attributes', () => {
TestBed.configureTestingModule({declarations: [MyComp, MyDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
const template = '<div>' + const template = '<div>' +
@ -1655,19 +1690,23 @@ function declareTests(config?: {useJit: boolean}) {
.toContain('ng-reflect-dir-prop="hello"'); .toContain('ng-reflect-dir-prop="hello"');
}); });
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
it(`should work with prop names containing '$'`, () => { it(`should work with prop names containing '$'`, () => {
TestBed.configureTestingModule({declarations: [ParentCmp, SomeCmpWithInput]}); TestBed.configureTestingModule({declarations: [ParentCmp, SomeCmpWithInput]});
const fixture = TestBed.createComponent(ParentCmp); const fixture = TestBed.createComponent(ParentCmp);
fixture.detectChanges(); fixture.detectChanges();
expect(getDOM().getInnerHTML(fixture.nativeElement)).toContain('ng-reflect-test_="hello"'); expect(getDOM().getInnerHTML(fixture.nativeElement))
.toContain('ng-reflect-test_="hello"');
}); });
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
it('should reflect property values on template comments', () => { it('should reflect property values on template comments', () => {
const fixture = const fixture =
TestBed.configureTestingModule({declarations: [MyComp]}) TestBed.configureTestingModule({declarations: [MyComp]})
.overrideComponent( .overrideComponent(
MyComp, {set: {template: '<ng-template [ngIf]="ctxBoolProp"></ng-template>'}}) MyComp,
{set: {template: '<ng-template [ngIf]="ctxBoolProp"></ng-template>'}})
.createComponent(MyComp); .createComponent(MyComp);
fixture.componentInstance.ctxBoolProp = true; fixture.componentInstance.ctxBoolProp = true;
@ -1677,6 +1716,7 @@ function declareTests(config?: {useJit: boolean}) {
.toContain('"ng\-reflect\-ng\-if"\: "true"'); .toContain('"ng\-reflect\-ng\-if"\: "true"');
}); });
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
it('should indicate when toString() throws', () => { it('should indicate when toString() throws', () => {
TestBed.configureTestingModule({declarations: [MyComp, MyDir]}); TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
const template = '<div my-dir [elprop]="toStringThrow"></div>'; const template = '<div my-dir [elprop]="toStringThrow"></div>';

View File

@ -15,7 +15,8 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy} from '@angular/private/testing'; import {fixmeIvy} from '@angular/private/testing';
{ {
fixmeIvy('unknown') && describe('Jit Summaries', () => { // ivy fix in https://github.com/angular/angular/pull/26871
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') && describe('Jit Summaries', () => {
let instances: Map<any, Base>; let instances: Map<any, Base>;
let summaries: () => any[]; let summaries: () => any[];

View File

@ -15,10 +15,10 @@ import {fixmeIvy} from '@angular/private/testing';
{ {
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); }); describe('no jit', () => { declareTests({useJit: false}); });
} }
} }
@ -38,6 +38,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
}); });
fixmeIvy('FW-663: ReferenceError: goog is not defined') &&
it('should support the "i18n" attribute', () => { it('should support the "i18n" attribute', () => {
const template = '<ng-container i18n>foo</ng-container>'; const template = '<ng-container i18n>foo</ng-container>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -49,6 +50,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(el).toHaveText('foo'); expect(el).toHaveText('foo');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
it('should be rendered as comment with children as siblings', () => { it('should be rendered as comment with children as siblings', () => {
const template = '<ng-container><p></p></ng-container>'; const template = '<ng-container><p></p></ng-container>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -63,6 +65,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P'); expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
it('should support nesting', () => { it('should support nesting', () => {
const template = const template =
'<ng-container>1</ng-container><ng-container><ng-container>2</ng-container></ng-container>'; '<ng-container>1</ng-container><ng-container><ng-container>2</ng-container></ng-container>';
@ -81,6 +84,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(children[4]).toHaveText('2'); expect(children[4]).toHaveText('2');
}); });
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
it('should group inner nodes', () => { it('should group inner nodes', () => {
const template = '<ng-container *ngIf="ctxBoolProp"><p></p><b></b></ng-container>'; const template = '<ng-container *ngIf="ctxBoolProp"><p></p><b></b></ng-container>';
TestBed.overrideComponent(MyComp, {set: {template}}); TestBed.overrideComponent(MyComp, {set: {template}});
@ -130,6 +134,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(dir.text).toEqual('container'); expect(dir.text).toEqual('container');
}); });
fixmeIvy('unknown') &&
it('should contain all direct child directives in a <ng-container> (content dom)', () => { it('should contain all direct child directives in a <ng-container> (content dom)', () => {
const template = const template =
'<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>'; '<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>';

View File

@ -100,11 +100,10 @@ class DummyConsole implements Console {
{ {
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
} }
} }
@ -144,6 +143,7 @@ function declareTests(config?: {useJit: boolean}) {
} }
describe('errors', () => { describe('errors', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error when exporting a directive that was neither declared nor imported', () => { it('should error when exporting a directive that was neither declared nor imported', () => {
@NgModule({exports: [SomeDirective]}) @NgModule({exports: [SomeDirective]})
class SomeModule { class SomeModule {
@ -154,6 +154,7 @@ function declareTests(config?: {useJit: boolean}) {
`Can't export directive ${stringify(SomeDirective)} from ${stringify(SomeModule)} as it was neither declared nor imported!`); `Can't export directive ${stringify(SomeDirective)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error when exporting a pipe that was neither declared nor imported', () => { it('should error when exporting a pipe that was neither declared nor imported', () => {
@NgModule({exports: [SomePipe]}) @NgModule({exports: [SomePipe]})
class SomeModule { class SomeModule {
@ -164,6 +165,7 @@ function declareTests(config?: {useJit: boolean}) {
`Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`); `Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error if a directive is declared in more than 1 module', () => { it('should error if a directive is declared in more than 1 module', () => {
@NgModule({declarations: [SomeDirective]}) @NgModule({declarations: [SomeDirective]})
class Module1 { class Module1 {
@ -182,6 +184,7 @@ function declareTests(config?: {useJit: boolean}) {
`You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`); `You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error if a directive is declared in more than 1 module also if the module declaring it is imported', it('should error if a directive is declared in more than 1 module also if the module declaring it is imported',
() => { () => {
@NgModule({declarations: [SomeDirective], exports: [SomeDirective]}) @NgModule({declarations: [SomeDirective], exports: [SomeDirective]})
@ -199,6 +202,7 @@ function declareTests(config?: {useJit: boolean}) {
`You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`); `You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error if a pipe is declared in more than 1 module', () => { it('should error if a pipe is declared in more than 1 module', () => {
@NgModule({declarations: [SomePipe]}) @NgModule({declarations: [SomePipe]})
class Module1 { class Module1 {
@ -217,6 +221,7 @@ function declareTests(config?: {useJit: boolean}) {
`You can also create a new NgModule that exports and includes ${stringify(SomePipe)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`); `You can also create a new NgModule that exports and includes ${stringify(SomePipe)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error if a pipe is declared in more than 1 module also if the module declaring it is imported', it('should error if a pipe is declared in more than 1 module also if the module declaring it is imported',
() => { () => {
@NgModule({declarations: [SomePipe], exports: [SomePipe]}) @NgModule({declarations: [SomePipe], exports: [SomePipe]})
@ -237,6 +242,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('schemas', () => { describe('schemas', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should error on unknown bound properties on custom elements by default', () => { it('should error on unknown bound properties on custom elements by default', () => {
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'}) @Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
class ComponentUsingInvalidProperty { class ComponentUsingInvalidProperty {
@ -249,14 +255,17 @@ function declareTests(config?: {useJit: boolean}) {
expect(() => createModule(SomeModule)).toThrowError(/Can't bind to 'someUnknownProp'/); expect(() => createModule(SomeModule)).toThrowError(/Can't bind to 'someUnknownProp'/);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not error on unknown bound properties on custom elements when using the CUSTOM_ELEMENTS_SCHEMA', it('should not error on unknown bound properties on custom elements when using the CUSTOM_ELEMENTS_SCHEMA',
() => { () => {
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'}) @Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
class ComponentUsingInvalidProperty { class ComponentUsingInvalidProperty {
} }
@NgModule( @NgModule({
{schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ComponentUsingInvalidProperty]}) schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ComponentUsingInvalidProperty]
})
class SomeModule { class SomeModule {
} }
@ -275,6 +284,7 @@ function declareTests(config?: {useJit: boolean}) {
afterEach(() => clearModulesForTest()); afterEach(() => clearModulesForTest());
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should register loaded modules', () => { it('should register loaded modules', () => {
createModule(SomeModule); createModule(SomeModule);
const factory = getModuleFactory(token); const factory = getModuleFactory(token);
@ -282,6 +292,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(factory.moduleType).toBe(SomeModule); expect(factory.moduleType).toBe(SomeModule);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when registering a duplicate module', () => { it('should throw when registering a duplicate module', () => {
createModule(SomeModule); createModule(SomeModule);
expect(() => createModule(SomeOtherModule)).toThrowError(/Duplicate module registered/); expect(() => createModule(SomeOtherModule)).toThrowError(/Duplicate module registered/);
@ -289,13 +300,15 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('entryComponents', () => { describe('entryComponents', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create ComponentFactories in root modules', () => { it('should create ComponentFactories in root modules', () => {
@NgModule({declarations: [SomeComp], entryComponents: [SomeComp]}) @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
class SomeModule { class SomeModule {
} }
const ngModule = createModule(SomeModule); const ngModule = createModule(SomeModule);
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType) expect(
ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
.toBe(SomeComp); .toBe(SomeComp);
expect(ngModule.injector.get(ComponentFactoryResolver) expect(ngModule.injector.get(ComponentFactoryResolver)
.resolveComponentFactory(SomeComp) .resolveComponentFactory(SomeComp)
@ -303,7 +316,9 @@ function declareTests(config?: {useJit: boolean}) {
.toBe(SomeComp); .toBe(SomeComp);
}); });
it('should throw if we cannot find a module associated with a module-level entryComponent', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw if we cannot find a module associated with a module-level entryComponent',
() => {
@Component({template: ''}) @Component({template: ''})
class SomeCompWithEntryComponents { class SomeCompWithEntryComponents {
} }
@ -317,6 +332,7 @@ function declareTests(config?: {useJit: boolean}) {
'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.'); 'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw if we cannot find a module associated with a component-level entryComponent', it('should throw if we cannot find a module associated with a component-level entryComponent',
() => { () => {
@Component({template: '', entryComponents: [SomeComp]}) @Component({template: '', entryComponents: [SomeComp]})
@ -332,6 +348,7 @@ function declareTests(config?: {useJit: boolean}) {
'Component SomeComp is not part of any NgModule or the module has not been imported into your module.'); 'Component SomeComp is not part of any NgModule or the module has not been imported into your module.');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => { it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => {
@NgModule({ @NgModule({
declarations: [SomeComp], declarations: [SomeComp],
@ -345,7 +362,8 @@ function declareTests(config?: {useJit: boolean}) {
} }
const ngModule = createModule(SomeModule); const ngModule = createModule(SomeModule);
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType) expect(
ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
.toBe(SomeComp); .toBe(SomeComp);
expect(ngModule.injector.get(ComponentFactoryResolver) expect(ngModule.injector.get(ComponentFactoryResolver)
.resolveComponentFactory(SomeComp) .resolveComponentFactory(SomeComp)
@ -353,6 +371,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBe(SomeComp); .toBe(SomeComp);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create ComponentFactories in imported modules', () => { it('should create ComponentFactories in imported modules', () => {
@NgModule({declarations: [SomeComp], entryComponents: [SomeComp]}) @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
class SomeImportedModule { class SomeImportedModule {
@ -363,7 +382,8 @@ function declareTests(config?: {useJit: boolean}) {
} }
const ngModule = createModule(SomeModule); const ngModule = createModule(SomeModule);
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType) expect(
ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
.toBe(SomeComp); .toBe(SomeComp);
expect(ngModule.injector.get(ComponentFactoryResolver) expect(ngModule.injector.get(ComponentFactoryResolver)
.resolveComponentFactory(SomeComp) .resolveComponentFactory(SomeComp)
@ -371,6 +391,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBe(SomeComp); .toBe(SomeComp);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create ComponentFactories if the component was imported', () => { it('should create ComponentFactories if the component was imported', () => {
@NgModule({declarations: [SomeComp], exports: [SomeComp]}) @NgModule({declarations: [SomeComp], exports: [SomeComp]})
class SomeImportedModule { class SomeImportedModule {
@ -381,7 +402,8 @@ function declareTests(config?: {useJit: boolean}) {
} }
const ngModule = createModule(SomeModule); const ngModule = createModule(SomeModule);
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType) expect(
ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
.toBe(SomeComp); .toBe(SomeComp);
expect(ngModule.injector.get(ComponentFactoryResolver) expect(ngModule.injector.get(ComponentFactoryResolver)
.resolveComponentFactory(SomeComp) .resolveComponentFactory(SomeComp)
@ -392,16 +414,19 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('bootstrap components', () => { describe('bootstrap components', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create ComponentFactories', () => { it('should create ComponentFactories', () => {
@NgModule({declarations: [SomeComp], bootstrap: [SomeComp]}) @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
class SomeModule { class SomeModule {
} }
const ngModule = createModule(SomeModule); const ngModule = createModule(SomeModule);
expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType) expect(
ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
.toBe(SomeComp); .toBe(SomeComp);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should store the ComponentFactories in the NgModuleInjector', () => { it('should store the ComponentFactories in the NgModuleInjector', () => {
@NgModule({declarations: [SomeComp], bootstrap: [SomeComp]}) @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
class SomeModule { class SomeModule {
@ -416,6 +441,7 @@ function declareTests(config?: {useJit: boolean}) {
describe('directives and pipes', () => { describe('directives and pipes', () => {
describe('declarations', () => { describe('declarations', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should be supported in root modules', () => { it('should be supported in root modules', () => {
@NgModule({ @NgModule({
declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe], declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
@ -431,6 +457,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBe('transformed someValue'); .toBe('transformed someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should be supported in imported modules', () => { it('should be supported in imported modules', () => {
@NgModule({ @NgModule({
declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe], declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
@ -450,6 +477,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should be supported in nested components', () => { it('should be supported in nested components', () => {
@Component({ @Component({
selector: 'parent', selector: 'parent',
@ -460,8 +488,8 @@ function declareTests(config?: {useJit: boolean}) {
@NgModule({ @NgModule({
declarations: [ declarations: [
ParentCompUsingModuleDirectiveAndPipe, CompUsingModuleDirectiveAndPipe, SomeDirective, ParentCompUsingModuleDirectiveAndPipe, CompUsingModuleDirectiveAndPipe,
SomePipe SomeDirective, SomePipe
], ],
entryComponents: [ParentCompUsingModuleDirectiveAndPipe] entryComponents: [ParentCompUsingModuleDirectiveAndPipe]
}) })
@ -477,8 +505,10 @@ function declareTests(config?: {useJit: boolean}) {
describe('import/export', () => { describe('import/export', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support exported directives and pipes', () => { it('should support exported directives and pipes', () => {
@NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]}) @NgModule(
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
class SomeImportedModule { class SomeImportedModule {
} }
@ -497,6 +527,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBe('transformed someValue'); .toBe('transformed someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`', it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`',
() => { () => {
@NgModule( @NgModule(
@ -519,8 +550,10 @@ function declareTests(config?: {useJit: boolean}) {
.toBe('transformed someValue'); .toBe('transformed someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support reexported modules', () => { it('should support reexported modules', () => {
@NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]}) @NgModule(
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
class SomeReexportedModule { class SomeReexportedModule {
} }
@ -542,8 +575,10 @@ function declareTests(config?: {useJit: boolean}) {
.toBe('transformed someValue'); .toBe('transformed someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support exporting individual directives of an imported module', () => { it('should support exporting individual directives of an imported module', () => {
@NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]}) @NgModule(
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
class SomeReexportedModule { class SomeReexportedModule {
} }
@ -565,6 +600,7 @@ function declareTests(config?: {useJit: boolean}) {
.toBe('transformed someValue'); .toBe('transformed someValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not use non exported pipes of an imported module', () => { it('should not use non exported pipes of an imported module', () => {
@NgModule({ @NgModule({
declarations: [SomePipe], declarations: [SomePipe],
@ -584,6 +620,7 @@ function declareTests(config?: {useJit: boolean}) {
.toThrowError(/The pipe 'somePipe' could not be found/); .toThrowError(/The pipe 'somePipe' could not be found/);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not use non exported directives of an imported module', () => { it('should not use non exported directives of an imported module', () => {
@NgModule({ @NgModule({
declarations: [SomeDirective], declarations: [SomeDirective],
@ -599,7 +636,8 @@ function declareTests(config?: {useJit: boolean}) {
class SomeModule { class SomeModule {
} }
expect(() => createComp(SomeComp, SomeModule)).toThrowError(/Can't bind to 'someDir'/); expect(() => createComp(SomeComp, SomeModule))
.toThrowError(/Can't bind to 'someDir'/);
}); });
}); });
}); });
@ -619,9 +657,11 @@ function declareTests(config?: {useJit: boolean}) {
return createModule(SomeModule, parent).injector; return createModule(SomeModule, parent).injector;
} }
it('should provide the module', fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide the module', () => {
() => { expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType); }); expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType);
});
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should instantiate a class without dependencies', () => { it('should instantiate a class without dependencies', () => {
const injector = createInjector([Engine]); const injector = createInjector([Engine]);
const engine = injector.get(Engine); const engine = injector.get(Engine);
@ -629,6 +669,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(engine).toBeAnInstanceOf(Engine); expect(engine).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should resolve dependencies based on type information', () => { it('should resolve dependencies based on type information', () => {
const injector = createInjector([Engine, Car]); const injector = createInjector([Engine, Car]);
const car = injector.get(Car); const car = injector.get(Car);
@ -637,6 +678,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(car.engine).toBeAnInstanceOf(Engine); expect(car.engine).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should resolve dependencies based on @Inject annotation', () => { it('should resolve dependencies based on @Inject annotation', () => {
const injector = createInjector([TurboEngine, Engine, CarWithInject]); const injector = createInjector([TurboEngine, Engine, CarWithInject]);
const car = injector.get(CarWithInject); const car = injector.get(CarWithInject);
@ -645,17 +687,19 @@ function declareTests(config?: {useJit: boolean}) {
expect(car.engine).toBeAnInstanceOf(TurboEngine); expect(car.engine).toBeAnInstanceOf(TurboEngine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when no type and not @Inject (class case)', () => { it('should throw when no type and not @Inject (class case)', () => {
expect(() => createInjector([NoAnnotations])) expect(() => createInjector([NoAnnotations]))
.toThrowError('Can\'t resolve all parameters for NoAnnotations: (?).'); .toThrowError('Can\'t resolve all parameters for NoAnnotations: (?).');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when no type and not @Inject (factory case)', () => { it('should throw when no type and not @Inject (factory case)', () => {
expect(() => createInjector([{provide: 'someToken', useFactory: factoryFn}])) expect(() => createInjector([{provide: 'someToken', useFactory: factoryFn}]))
.toThrowError('Can\'t resolve all parameters for factoryFn: (?).'); .toThrowError('Can\'t resolve all parameters for factoryFn: (?).');
}); });
it('should cache instances', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should cache instances', () => {
const injector = createInjector([Engine]); const injector = createInjector([Engine]);
const e1 = injector.get(Engine); const e1 = injector.get(Engine);
@ -664,31 +708,33 @@ function declareTests(config?: {useJit: boolean}) {
expect(e1).toBe(e2); expect(e1).toBe(e2);
}); });
it('should provide to a value', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide to a value', () => {
const injector = createInjector([{provide: Engine, useValue: 'fake engine'}]); const injector = createInjector([{provide: Engine, useValue: 'fake engine'}]);
const engine = injector.get(Engine); const engine = injector.get(Engine);
expect(engine).toEqual('fake engine'); expect(engine).toEqual('fake engine');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should provide to a factory', () => { it('should provide to a factory', () => {
function sportsCarFactory(e: Engine) { return new SportsCar(e); } function sportsCarFactory(e: Engine) { return new SportsCar(e); }
const injector = const injector = createInjector(
createInjector([Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]); [Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
const car = injector.get(Car); const car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar); expect(car).toBeAnInstanceOf(SportsCar);
expect(car.engine).toBeAnInstanceOf(Engine); expect(car.engine).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should supporting provider to null', () => { it('should supporting provider to null', () => {
const injector = createInjector([{provide: Engine, useValue: null}]); const injector = createInjector([{provide: Engine, useValue: null}]);
const engine = injector.get(Engine); const engine = injector.get(Engine);
expect(engine).toBeNull(); expect(engine).toBeNull();
}); });
it('should provide to an alias', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide to an alias', () => {
const injector = createInjector([ const injector = createInjector([
Engine, {provide: SportsCar, useClass: SportsCar}, Engine, {provide: SportsCar, useClass: SportsCar},
{provide: Car, useExisting: SportsCar} {provide: Car, useExisting: SportsCar}
@ -700,6 +746,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(car).toBe(sportsCar); expect(car).toBe(sportsCar);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support multiProviders', () => { it('should support multiProviders', () => {
const injector = createInjector([ const injector = createInjector([
Engine, {provide: CARS, useClass: SportsCar, multi: true}, Engine, {provide: CARS, useClass: SportsCar, multi: true},
@ -712,6 +759,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine); expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support multiProviders that are created using useExisting', () => { it('should support multiProviders that are created using useExisting', () => {
const injector = createInjector( const injector = createInjector(
[Engine, SportsCar, {provide: CARS, useExisting: SportsCar, multi: true}]); [Engine, SportsCar, {provide: CARS, useExisting: SportsCar, multi: true}]);
@ -721,12 +769,14 @@ function declareTests(config?: {useJit: boolean}) {
expect(cars[0]).toBe(injector.get(SportsCar)); expect(cars[0]).toBe(injector.get(SportsCar));
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when the aliased provider does not exist', () => { it('should throw when the aliased provider does not exist', () => {
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]); const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`; const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
expect(() => injector.get('car')).toThrowError(e); expect(() => injector.get('car')).toThrowError(e);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should handle forwardRef in useExisting', () => { it('should handle forwardRef in useExisting', () => {
const injector = createInjector([ const injector = createInjector([
{provide: 'originalEngine', useClass: forwardRef(() => Engine)}, {provide: 'originalEngine', useClass: forwardRef(() => Engine)},
@ -735,15 +785,18 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine); expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support overriding factory dependencies', () => { it('should support overriding factory dependencies', () => {
const injector = createInjector( const injector = createInjector([
[Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}]); Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}
]);
const car = injector.get(Car); const car = injector.get(Car);
expect(car).toBeAnInstanceOf(SportsCar); expect(car).toBeAnInstanceOf(SportsCar);
expect(car.engine).toBeAnInstanceOf(Engine); expect(car.engine).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support optional dependencies', () => { it('should support optional dependencies', () => {
const injector = createInjector([CarWithOptionalEngine]); const injector = createInjector([CarWithOptionalEngine]);
@ -751,6 +804,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(car.engine).toBeNull(); expect(car.engine).toBeNull();
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should flatten passed-in providers', () => { it('should flatten passed-in providers', () => {
const injector = createInjector([[[Engine, Car]]]); const injector = createInjector([[[Engine, Car]]]);
@ -758,39 +812,43 @@ function declareTests(config?: {useJit: boolean}) {
expect(car).toBeAnInstanceOf(Car); expect(car).toBeAnInstanceOf(Car);
}); });
it('should use the last provider when there are multiple providers for same token', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should use the last provider when there are multiple providers for same token',
() => {
const injector = createInjector( const injector = createInjector(
[{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]); [{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]);
expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine); expect(injector.get(Engine)).toBeAnInstanceOf(TurboEngine);
}); });
it('should use non-type tokens', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should use non-type tokens', () => {
const injector = createInjector([{provide: 'token', useValue: 'value'}]); const injector = createInjector([{provide: 'token', useValue: 'value'}]);
expect(injector.get('token')).toEqual('value'); expect(injector.get('token')).toEqual('value');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when given invalid providers', () => { it('should throw when given invalid providers', () => {
expect(() => createInjector(<any>['blah'])) expect(() => createInjector(<any>['blah']))
.toThrowError( .toThrowError(
`Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?blah?]`); `Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?blah?]`);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when given blank providers', () => { it('should throw when given blank providers', () => {
expect(() => createInjector(<any>[null, {provide: 'token', useValue: 'value'}])) expect(() => createInjector(<any>[null, {provide: 'token', useValue: 'value'}]))
.toThrowError( .toThrowError(
`Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?null?, ...]`); `Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?null?, ...]`);
}); });
it('should provide itself', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide itself', () => {
const parent = createInjector([]); const parent = createInjector([]);
const child = createInjector([], parent); const child = createInjector([], parent);
expect(child.get(Injector)).toBe(child); expect(child.get(Injector)).toBe(child);
}); });
it('should provide undefined', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide undefined', () => {
let factoryCounter = 0; let factoryCounter = 0;
const injector = createInjector([{ const injector = createInjector([{
@ -808,6 +866,7 @@ function declareTests(config?: {useJit: boolean}) {
describe('injecting lazy providers into an eager provider via Injector.get', () => { describe('injecting lazy providers into an eager provider via Injector.get', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should inject providers that were declared before it', () => { it('should inject providers that were declared before it', () => {
@NgModule({ @NgModule({
providers: [ providers: [
@ -827,6 +886,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue'); expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should inject providers that were declared after it', () => { it('should inject providers that were declared after it', () => {
@NgModule({ @NgModule({
providers: [ providers: [
@ -849,6 +909,7 @@ function declareTests(config?: {useJit: boolean}) {
describe('injecting eager providers into an eager provider via Injector.get', () => { describe('injecting eager providers into an eager provider via Injector.get', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should inject providers that were declared before it', () => { it('should inject providers that were declared before it', () => {
@NgModule({ @NgModule({
providers: [ providers: [
@ -868,6 +929,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(createModule(MyModule).injector.get('eager2')).toBe('v2: v1'); expect(createModule(MyModule).injector.get('eager2')).toBe('v2: v1');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should inject providers that were declared after it', () => { it('should inject providers that were declared after it', () => {
@NgModule({ @NgModule({
providers: [ providers: [
@ -887,6 +949,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(createModule(MyModule).injector.get('eager1')).toBe('v1: v2'); expect(createModule(MyModule).injector.get('eager1')).toBe('v1: v2');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('eager providers should get initialized only once', () => { it('eager providers should get initialized only once', () => {
@Injectable() @Injectable()
class MyService1 { class MyService1 {
@ -917,24 +980,27 @@ function declareTests(config?: {useJit: boolean}) {
}); });
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when no provider defined', () => { it('should throw when no provider defined', () => {
const injector = createInjector([]); const injector = createInjector([]);
expect(() => injector.get('NonExisting')) expect(() => injector.get('NonExisting'))
.toThrowError('NullInjectorError: No provider for NonExisting!'); .toThrowError('NullInjectorError: No provider for NonExisting!');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should throw when trying to instantiate a cyclic dependency', () => { it('should throw when trying to instantiate a cyclic dependency', () => {
expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}])) expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}]))
.toThrowError(/Cannot instantiate cyclic dependency! Car/g); .toThrowError(/Cannot instantiate cyclic dependency! Car/g);
}); });
it('should support null values', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should support null values', () => {
const injector = createInjector([{provide: 'null', useValue: null}]); const injector = createInjector([{provide: 'null', useValue: null}]);
expect(injector.get('null')).toBe(null); expect(injector.get('null')).toBe(null);
}); });
describe('child', () => { describe('child', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should load instances from parent injector', () => { it('should load instances from parent injector', () => {
const parent = createInjector([Engine]); const parent = createInjector([Engine]);
const child = createInjector([], parent); const child = createInjector([], parent);
@ -945,6 +1011,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(engineFromChild).toBe(engineFromParent); expect(engineFromChild).toBe(engineFromParent);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not use the child providers when resolving the dependencies of a parent provider', it('should not use the child providers when resolving the dependencies of a parent provider',
() => { () => {
const parent = createInjector([Car, Engine]); const parent = createInjector([Car, Engine]);
@ -954,6 +1021,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(carFromChild.engine).toBeAnInstanceOf(Engine); expect(carFromChild.engine).toBeAnInstanceOf(Engine);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should create new instance in a child injector', () => { it('should create new instance in a child injector', () => {
const parent = createInjector([Engine]); const parent = createInjector([Engine]);
const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent); const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
@ -969,10 +1037,14 @@ function declareTests(config?: {useJit: boolean}) {
describe('depedency resolution', () => { describe('depedency resolution', () => {
describe('@Self()', () => { describe('@Self()', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should return a dependency from self', () => { it('should return a dependency from self', () => {
const inj = createInjector([ const inj = createInjector([
Engine, Engine, {
{provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]} provide: Car,
useFactory: (e: Engine) => new Car(e),
deps: [[Engine, new Self()]]
}
]); ]);
expect(inj.get(Car)).toBeAnInstanceOf(Car); expect(inj.get(Car)).toBeAnInstanceOf(Car);
@ -980,7 +1052,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('default', () => { describe('default', () => {
it('should not skip self', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should not skip self', () => {
const parent = createInjector([Engine]); const parent = createInjector([Engine]);
const child = createInjector( const child = createInjector(
[ [
@ -995,7 +1067,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('lifecycle', () => { describe('lifecycle', () => {
it('should instantiate modules eagerly', () => { fixmeIvy('unknown') && it('should instantiate modules eagerly', () => {
let created = false; let created = false;
@NgModule() @NgModule()
@ -1012,6 +1084,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(created).toBe(true); expect(created).toBe(true);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should instantiate providers that are not used by a module lazily', () => { it('should instantiate providers that are not used by a module lazily', () => {
let created = false; let created = false;
@ -1026,6 +1099,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(created).toBe(false); expect(created).toBe(false);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support ngOnDestroy on any provider', () => { it('should support ngOnDestroy on any provider', () => {
let destroyed = false; let destroyed = false;
@ -1045,6 +1119,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(destroyed).toBe(true); expect(destroyed).toBe(true);
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should support ngOnDestroy for lazy providers', () => { it('should support ngOnDestroy for lazy providers', () => {
let created = false; let created = false;
let destroyed = false; let destroyed = false;
@ -1076,6 +1151,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('imported and exported modules', () => { describe('imported and exported modules', () => {
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should add the providers of imported modules', () => { it('should add the providers of imported modules', () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
class ImportedModule { class ImportedModule {
@ -1092,15 +1168,17 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('imported'); expect(injector.get('token1')).toBe('imported');
}); });
fixmeIvy('unknown') &&
it('should add the providers of imported ModuleWithProviders', () => { it('should add the providers of imported ModuleWithProviders', () => {
@NgModule() @NgModule()
class ImportedModule { class ImportedModule {
} }
@NgModule({ @NgModule({
imports: [ imports: [{
{ngModule: ImportedModule, providers: [{provide: 'token1', useValue: 'imported'}]} ngModule: ImportedModule,
] providers: [{provide: 'token1', useValue: 'imported'}]
}]
}) })
class SomeModule { class SomeModule {
} }
@ -1112,6 +1190,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('imported'); expect(injector.get('token1')).toBe('imported');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of imported modules', () => { it('should overwrite the providers of imported modules', () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
class ImportedModule { class ImportedModule {
@ -1126,6 +1205,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('direct'); expect(injector.get('token1')).toBe('direct');
}); });
fixmeIvy('unknown') &&
it('should overwrite the providers of imported ModuleWithProviders', () => { it('should overwrite the providers of imported ModuleWithProviders', () => {
@NgModule() @NgModule()
class ImportedModule { class ImportedModule {
@ -1133,9 +1213,10 @@ function declareTests(config?: {useJit: boolean}) {
@NgModule({ @NgModule({
providers: [{provide: 'token1', useValue: 'direct'}], providers: [{provide: 'token1', useValue: 'direct'}],
imports: [ imports: [{
{ngModule: ImportedModule, providers: [{provide: 'token1', useValue: 'imported'}]} ngModule: ImportedModule,
] providers: [{provide: 'token1', useValue: 'imported'}]
}]
}) })
class SomeModule { class SomeModule {
} }
@ -1144,7 +1225,9 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('direct'); expect(injector.get('token1')).toBe('direct');
}); });
it('should overwrite the providers of imported modules on the second import level', () => { fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of imported modules on the second import level',
() => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
class ImportedModuleLevel2 { class ImportedModuleLevel2 {
} }
@ -1164,6 +1247,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('direct'); expect(injector.get('token1')).toBe('direct');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should add the providers of exported modules', () => { it('should add the providers of exported modules', () => {
@NgModule({providers: [{provide: 'token1', useValue: 'exported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
class ExportedValue { class ExportedValue {
@ -1180,6 +1264,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('exported'); expect(injector.get('token1')).toBe('exported');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of exported modules', () => { it('should overwrite the providers of exported modules', () => {
@NgModule({providers: [{provide: 'token1', useValue: 'exported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
class ExportedModule { class ExportedModule {
@ -1194,6 +1279,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('direct'); expect(injector.get('token1')).toBe('direct');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of imported modules by following imported modules', it('should overwrite the providers of imported modules by following imported modules',
() => { () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
@ -1212,6 +1298,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('imported2'); expect(injector.get('token1')).toBe('imported2');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of exported modules by following exported modules', it('should overwrite the providers of exported modules by following exported modules',
() => { () => {
@NgModule({providers: [{provide: 'token1', useValue: 'exported1'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'exported1'}]})
@ -1230,6 +1317,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('exported2'); expect(injector.get('token1')).toBe('exported2');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should overwrite the providers of imported modules by exported modules', () => { it('should overwrite the providers of imported modules by exported modules', () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
class ImportedModule { class ImportedModule {
@ -1247,6 +1335,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('exported'); expect(injector.get('token1')).toBe('exported');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not overwrite the providers if a module was already used on the same level', it('should not overwrite the providers if a module was already used on the same level',
() => { () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
@ -1265,6 +1354,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('imported2'); expect(injector.get('token1')).toBe('imported2');
}); });
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
it('should not overwrite the providers if a module was already used on a child level', it('should not overwrite the providers if a module was already used on a child level',
() => { () => {
@NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]}) @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
@ -1287,6 +1377,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get('token1')).toBe('imported2'); expect(injector.get('token1')).toBe('imported2');
}); });
fixmeIvy('unknown') &&
it('should throw when given invalid providers in an imported ModuleWithProviders', () => { it('should throw when given invalid providers in an imported ModuleWithProviders', () => {
@NgModule() @NgModule()
class ImportedModule1 { class ImportedModule1 {
@ -1303,6 +1394,7 @@ function declareTests(config?: {useJit: boolean}) {
}); });
describe('tree shakable providers', () => { describe('tree shakable providers', () => {
fixmeIvy('unknown') &&
it('definition should not persist across NgModuleRef instances', () => { it('definition should not persist across NgModuleRef instances', () => {
@NgModule() @NgModule()
class SomeModule { class SomeModule {
@ -1322,13 +1414,15 @@ function declareTests(config?: {useJit: boolean}) {
ngModuleRef1.injector.get(Bar); ngModuleRef1.injector.get(Bar);
// Tree Shakeable provider definition should get added to the NgModule data. // Tree Shakeable provider definition should get added to the NgModule data.
const providerDef1 = (ngModuleRef1 as NgModuleData)._def.providersByKey[tokenKey(Bar)]; const providerDef1 =
(ngModuleRef1 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
expect(providerDef1).not.toBeUndefined(); expect(providerDef1).not.toBeUndefined();
// Instantiate the same module. The tree shakeable provider // Instantiate the same module. The tree shakeable provider
// definition should not already be present. // definition should not already be present.
const ngModuleRef2 = factory.create(null); const ngModuleRef2 = factory.create(null);
const providerDef2 = (ngModuleRef2 as NgModuleData)._def.providersByKey[tokenKey(Bar)]; const providerDef2 =
(ngModuleRef2 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
expect(providerDef2).toBeUndefined(); expect(providerDef2).toBeUndefined();
}); });
}); });

View File

@ -14,7 +14,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy} from '@angular/private/testing'; import {fixmeIvy} from '@angular/private/testing';
{ {
fixmeIvy('unknown') && describe('projection', () => { describe('projection', () => {
beforeEach(() => TestBed.configureTestingModule({declarations: [MainComp, OtherComp, Simple]})); beforeEach(() => TestBed.configureTestingModule({declarations: [MainComp, OtherComp, Simple]}));
it('should support simple components', () => { it('should support simple components', () => {
@ -82,7 +82,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText(''); expect(main.nativeElement).toHaveText('');
}); });
it('should support multiple content tags', () => { fixmeIvy('unknown') && it('should support multiple content tags', () => {
TestBed.configureTestingModule({declarations: [MultipleContentTagsComponent]}); TestBed.configureTestingModule({declarations: [MultipleContentTagsComponent]});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
set: { set: {
@ -113,6 +113,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('(, BAC)'); expect(main.nativeElement).toHaveText('(, BAC)');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should redistribute direct child viewcontainers when the light dom changes', () => { it('should redistribute direct child viewcontainers when the light dom changes', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [MultipleContentTagsComponent, ManualViewportDirective]}); {declarations: [MultipleContentTagsComponent, ManualViewportDirective]});
@ -156,6 +157,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))'); expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should support nesting with content being direct child of a nested component', () => { it('should support nesting with content being direct child of a nested component', () => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: declarations:
@ -173,8 +175,8 @@ import {fixmeIvy} from '@angular/private/testing';
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const viewportDirective = const viewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0]
ManualViewportDirective); .injector.get(ManualViewportDirective);
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))'); expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
viewportDirective.show(); viewportDirective.show();
@ -182,7 +184,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))'); expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(A,BC)))');
}); });
it('should redistribute when the shadow dom changes', () => { fixmeIvy('unknown') && it('should redistribute when the shadow dom changes', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalContentComponent, ManualViewportDirective]}); {declarations: [ConditionalContentComponent, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
@ -237,6 +239,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('P,text'); expect(main.nativeElement).toHaveText('P,text');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should support moving non projected light dom around', () => { it('should support moving non projected light dom around', () => {
let sourceDirective: ManualViewportDirective = undefined !; let sourceDirective: ManualViewportDirective = undefined !;
@ -267,7 +270,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('START(A)END'); expect(main.nativeElement).toHaveText('START(A)END');
}); });
it('should support moving projected light dom around', () => { fixmeIvy('unknown') && it('should support moving projected light dom around', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [Empty, ProjectDirective, ManualViewportDirective]}); {declarations: [Empty, ProjectDirective, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
@ -290,9 +293,12 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('SIMPLE()START(A)END'); expect(main.nativeElement).toHaveText('SIMPLE()START(A)END');
}); });
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should support moving ng-content around', () => { it('should support moving ng-content around', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule({
{declarations: [ConditionalContentComponent, ProjectDirective, ManualViewportDirective]}); declarations:
[ConditionalContentComponent, ProjectDirective, ManualViewportDirective]
});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {
set: { set: {
template: '<conditional-content>' + template: '<conditional-content>' +
@ -305,8 +311,8 @@ import {fixmeIvy} from '@angular/private/testing';
const main = TestBed.createComponent(MainComp); const main = TestBed.createComponent(MainComp);
const sourceDirective: ManualViewportDirective = const sourceDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0]
ManualViewportDirective); .injector.get(ManualViewportDirective);
const projectDirective: ProjectDirective = const projectDirective: ProjectDirective =
main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get( main.debugElement.queryAllNodes(By.directive(ProjectDirective))[0].injector.get(
ProjectDirective); ProjectDirective);
@ -324,6 +330,7 @@ import {fixmeIvy} from '@angular/private/testing';
// Note: This does not use a ng-content element, but // Note: This does not use a ng-content element, but
// is still important as we are merging proto views independent of // is still important as we are merging proto views independent of
// the presence of ng-content elements! // the presence of ng-content elements!
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should still allow to implement a recursive trees', () => { it('should still allow to implement a recursive trees', () => {
TestBed.configureTestingModule({declarations: [Tree, ManualViewportDirective]}); TestBed.configureTestingModule({declarations: [Tree, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, {set: {template: '<tree></tree>'}}); TestBed.overrideComponent(MainComp, {set: {template: '<tree></tree>'}});
@ -331,8 +338,8 @@ import {fixmeIvy} from '@angular/private/testing';
main.detectChanges(); main.detectChanges();
const manualDirective: ManualViewportDirective = const manualDirective: ManualViewportDirective =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0]
ManualViewportDirective); .injector.get(ManualViewportDirective);
expect(main.nativeElement).toHaveText('TREE(0:)'); expect(main.nativeElement).toHaveText('TREE(0:)');
manualDirective.show(); manualDirective.show();
main.detectChanges(); main.detectChanges();
@ -342,6 +349,7 @@ import {fixmeIvy} from '@angular/private/testing';
// Note: This does not use a ng-content element, but // Note: This does not use a ng-content element, but
// is still important as we are merging proto views independent of // is still important as we are merging proto views independent of
// the presence of ng-content elements! // the presence of ng-content elements!
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should still allow to implement a recursive trees via multiple components', () => { it('should still allow to implement a recursive trees via multiple components', () => {
TestBed.configureTestingModule({declarations: [Tree, Tree2, ManualViewportDirective]}); TestBed.configureTestingModule({declarations: [Tree, Tree2, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, {set: {template: '<tree></tree>'}}); TestBed.overrideComponent(MainComp, {set: {template: '<tree></tree>'}});
@ -361,7 +369,8 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('TREE(0:TREE2(1:))'); expect(main.nativeElement).toHaveText('TREE(0:TREE2(1:))');
const tree2 = main.debugElement.query(By.directive(Tree2)); const tree2 = main.debugElement.query(By.directive(Tree2));
manualDirective = tree2.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get( manualDirective =
tree2.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
ManualViewportDirective); ManualViewportDirective);
manualDirective.show(); manualDirective.show();
main.detectChanges(); main.detectChanges();
@ -427,6 +436,7 @@ import {fixmeIvy} from '@angular/private/testing';
}); });
} }
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
it('should support nested conditionals that contain ng-contents', () => { it('should support nested conditionals that contain ng-contents', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalTextComponent, ManualViewportDirective]}); {declarations: [ConditionalTextComponent, ManualViewportDirective]});
@ -441,11 +451,13 @@ import {fixmeIvy} from '@angular/private/testing';
viewportElement.injector.get(ManualViewportDirective).show(); viewportElement.injector.get(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST())'); expect(main.nativeElement).toHaveText('MAIN(FIRST())');
viewportElement = main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[1]; viewportElement =
main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[1];
viewportElement.injector.get(ManualViewportDirective).show(); viewportElement.injector.get(ManualViewportDirective).show();
expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))'); expect(main.nativeElement).toHaveText('MAIN(FIRST(SECOND(a)))');
}); });
fixmeIvy('unknown') &&
it('should allow to switch the order of nested components via ng-content', () => { it('should allow to switch the order of nested components via ng-content', () => {
TestBed.configureTestingModule({declarations: [CmpA, CmpB, CmpD, CmpC]}); TestBed.configureTestingModule({declarations: [CmpA, CmpB, CmpD, CmpC]});
TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a><cmp-b></cmp-b></cmp-a>`}}); TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a><cmp-b></cmp-b></cmp-a>`}});
@ -458,7 +470,7 @@ import {fixmeIvy} from '@angular/private/testing';
'<cmp-c><b>cmp-c</b></cmp-c></cmp-a>'); '<cmp-c><b>cmp-c</b></cmp-c></cmp-a>');
}); });
it('should create nested components in the right order', () => { fixmeIvy('unknown') && it('should create nested components in the right order', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [CmpA1, CmpA2, CmpB11, CmpB12, CmpB21, CmpB22]}); {declarations: [CmpA1, CmpA2, CmpB11, CmpB12, CmpB21, CmpB22]});
TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`}}); TestBed.overrideComponent(MainComp, {set: {template: `<cmp-a1></cmp-a1><cmp-a2></cmp-a2>`}});
@ -471,7 +483,7 @@ import {fixmeIvy} from '@angular/private/testing';
'<cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>'); '<cmp-a2>a2<cmp-b21>b21</cmp-b21><cmp-b22>b22</cmp-b22></cmp-a2>');
}); });
it('should project filled view containers into a view container', () => { fixmeIvy('unknown') && it('should project filled view containers into a view container', () => {
TestBed.configureTestingModule( TestBed.configureTestingModule(
{declarations: [ConditionalContentComponent, ManualViewportDirective]}); {declarations: [ConditionalContentComponent, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, { TestBed.overrideComponent(MainComp, {

View File

@ -14,8 +14,8 @@ import {Subject} from 'rxjs';
import {stringify} from '../../src/util'; import {stringify} from '../../src/util';
{ // FW-670: Internal Error: The name q is already defined in scope
fixmeIvy('unknown') && describe('Query API', () => { fixmeIvy('FW-670') && describe('Query API', () => {
beforeEach(() => TestBed.configureTestingModule({ beforeEach(() => TestBed.configureTestingModule({
declarations: [ declarations: [
@ -66,8 +66,7 @@ import {stringify} from '../../src/util';
}); });
it('should contain all direct child directives in the content dom', () => { it('should contain all direct child directives in the content dom', () => {
const template = const template = '<needs-content-children #q><div text="foo"></div></needs-content-children>';
'<needs-content-children #q><div text="foo"></div></needs-content-children>';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q']; const q = view.debugElement.children[0].references !['q'];
@ -232,8 +231,7 @@ import {stringify} from '../../src/util';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
const needsTpl: NeedsTpl = view.debugElement.children[0].injector.get(NeedsTpl); const needsTpl: NeedsTpl = view.debugElement.children[0].injector.get(NeedsTpl);
expect(needsTpl.vc.createEmbeddedView(needsTpl.query.first).rootNodes[0]) expect(needsTpl.vc.createEmbeddedView(needsTpl.query.first).rootNodes[0]).toHaveText('light');
.toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewQuery.first).rootNodes[0]) expect(needsTpl.vc.createEmbeddedView(needsTpl.viewQuery.first).rootNodes[0])
.toHaveText('shadow'); .toHaveText('shadow');
}); });
@ -243,8 +241,7 @@ import {stringify} from '../../src/util';
'<needs-named-tpl><ng-template #tpl><div>light</div></ng-template></needs-named-tpl>'; '<needs-named-tpl><ng-template #tpl><div>light</div></ng-template></needs-named-tpl>';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
const needsTpl: NeedsNamedTpl = view.debugElement.children[0].injector.get(NeedsNamedTpl); const needsTpl: NeedsNamedTpl = view.debugElement.children[0].injector.get(NeedsNamedTpl);
expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0]) expect(needsTpl.vc.createEmbeddedView(needsTpl.contentTpl).rootNodes[0]).toHaveText('light');
.toHaveText('light');
expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0]).toHaveText('shadow'); expect(needsTpl.vc.createEmbeddedView(needsTpl.viewTpl).rootNodes[0]).toHaveText('shadow');
}); });
}); });
@ -286,7 +283,19 @@ import {stringify} from '../../src/util';
'</needs-content-child-template-ref-app>'; '</needs-content-child-template-ref-app>';
const view = createTestCmp(MyComp0, template); const view = createTestCmp(MyComp0, template);
// can't execute checkNoChanges as our view modifies our content children (via a query). // can't
// execute
// checkNoChanges
// as
// our
// view
// modifies
// our
// content
// children
// (via
// a
// query).
view.detectChanges(false); view.detectChanges(false);
expect(view.nativeElement).toHaveText('OUTER'); expect(view.nativeElement).toHaveText('OUTER');
}); });
@ -344,8 +353,7 @@ import {stringify} from '../../src/util';
it('should correctly clean-up when destroyed together with the directives it is querying', it('should correctly clean-up when destroyed together with the directives it is querying',
() => { () => {
const template = const template = '<needs-query #q *ngIf="shouldShow"><div text="foo"></div></needs-query>';
'<needs-query #q *ngIf="shouldShow"><div text="foo"></div></needs-query>';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
view.componentInstance.shouldShow = true; view.componentInstance.shouldShow = true;
view.detectChanges(); view.detectChanges();
@ -526,7 +534,15 @@ import {stringify} from '../../src/util';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
const q: NeedsViewQueryOrder = view.debugElement.children[0].references !['q']; const q: NeedsViewQueryOrder = view.debugElement.children[0].references !['q'];
// no significance to 50, just a reasonably large cycle. // no
// significance
// to
// 50,
// just
// a
// reasonably
// large
// cycle.
for (let i = 0; i < 50; i++) { for (let i = 0; i < 50; i++) {
const newString = i.toString(); const newString = i.toString();
q.list = [newString]; q.list = [newString];
@ -563,8 +579,21 @@ import {stringify} from '../../src/util';
expect(q.query.length).toBe(0); expect(q.query.length).toBe(0);
}); });
// Note: This tests is just document our current behavior, which we do // Note:
// for performance reasons. // This
// tests
// is
// just
// document
// our
// current
// behavior,
// which
// we
// do
// for
// performance
// reasons.
it('should not affected queries for projected templates if views are detached or moved', () => { it('should not affected queries for projected templates if views are detached or moved', () => {
const template = const template =
'<manual-projecting #q><ng-template let-x="x"><div [text]="x"></div></ng-template></manual-projecting>'; '<manual-projecting #q><ng-template let-x="x"><div [text]="x"></div></ng-template></manual-projecting>';
@ -614,11 +643,15 @@ import {stringify} from '../../src/util';
@Component( @Component(
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'}) {selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
class AutoProjecting { class AutoProjecting {
// TODO(issue/24571): remove '!'. // TODO(issue/24571):
// remove
// '!'.
@ContentChild(TemplateRef) @ContentChild(TemplateRef)
content !: TemplateRef<any>; content !: TemplateRef<any>;
// TODO(issue/24571): remove '!'. // TODO(issue/24571):
// remove
// '!'.
@ContentChildren(TextDirective) @ContentChildren(TextDirective)
query !: QueryList<TextDirective>; query !: QueryList<TextDirective>;
} }
@ -629,14 +662,23 @@ import {stringify} from '../../src/util';
const view = createTestCmpAndDetectChanges(MyComp0, template); const view = createTestCmpAndDetectChanges(MyComp0, template);
const q = view.debugElement.children[0].references !['q']; const q = view.debugElement.children[0].references !['q'];
// This should be 1, but due to // This
// https://github.com/angular/angular/issues/15117 this is 0. // should
// be
// 1,
// but
// due
// to
// https://github.com/angular/angular/issues/15117
// this
// is
// 0.
expect(q.query.length).toBe(0); expect(q.query.length).toBe(0);
}); });
}); });
}); });
}
@Directive({selector: '[text]', inputs: ['text'], exportAs: 'textDir'}) @Directive({selector: '[text]', inputs: ['text'], exportAs: 'textDir'})
class TextDirective { class TextDirective {

View File

@ -7,7 +7,7 @@
*/ */
import {ANALYZE_FOR_ENTRY_COMPONENTS, ApplicationRef, Component, ComponentRef, ContentChild, Directive, ErrorHandler, EventEmitter, HostListener, InjectionToken, Injector, Input, NgModule, NgModuleRef, NgZone, Output, Pipe, PipeTransform, Provider, QueryList, Renderer2, SimpleChanges, TemplateRef, ViewChildren, ViewContainerRef, destroyPlatform, ɵivyEnabled as ivyEnabled} from '@angular/core'; import {ANALYZE_FOR_ENTRY_COMPONENTS, ApplicationRef, Component, ComponentRef, ContentChild, Directive, ErrorHandler, EventEmitter, HostListener, InjectionToken, Injector, Input, NgModule, NgModuleRef, NgZone, Output, Pipe, PipeTransform, Provider, QueryList, Renderer2, SimpleChanges, TemplateRef, ViewChildren, ViewContainerRef, destroyPlatform, ɵivyEnabled as ivyEnabled} from '@angular/core';
import {TestBed, async, fakeAsync, inject, tick} from '@angular/core/testing'; import {TestBed, fakeAsync, inject, tick} from '@angular/core/testing';
import {BrowserModule, By, DOCUMENT} from '@angular/platform-browser'; import {BrowserModule, By, DOCUMENT} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
@ -16,11 +16,10 @@ import {fixmeIvy} from '@angular/private/testing';
{ {
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
} }
declareTestsUsingBootstrap(); declareTestsUsingBootstrap();
@ -35,7 +34,7 @@ function declareTests(config?: {useJit: boolean}) {
describe('platform pipes', () => { describe('platform pipes', () => {
beforeEach(() => { TestBed.configureCompiler({...config}); }); beforeEach(() => { TestBed.configureCompiler({...config}); });
it('should overwrite them by custom pipes', () => { fixmeIvy('unknown') && it('should overwrite them by custom pipes', () => {
TestBed.configureTestingModule({declarations: [CustomPipe]}); TestBed.configureTestingModule({declarations: [CustomPipe]});
const template = '{{true | somePipe}}'; const template = '{{true | somePipe}}';
TestBed.overrideComponent(MyComp1, {set: {template}}); TestBed.overrideComponent(MyComp1, {set: {template}});
@ -77,7 +76,9 @@ function declareTests(config?: {useJit: boolean}) {
expect(CountingPipe.calls).toBe(1); expect(CountingPipe.calls).toBe(1);
}); });
it('should only update the bound property when using asyncPipe - #15205', fakeAsync(() => { fixmeIvy('unknown') &&
it('should only update the bound property when using asyncPipe - #15205',
fakeAsync(() => {
@Component({template: '<div myDir [a]="p | async" [b]="2"></div>'}) @Component({template: '<div myDir [a]="p | async" [b]="2"></div>'})
class MyComp { class MyComp {
p = Promise.resolve(1); p = Promise.resolve(1);
@ -99,7 +100,8 @@ function declareTests(config?: {useJit: boolean}) {
TestBed.configureTestingModule({declarations: [MyDir, MyComp]}); TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
const fixture = TestBed.createComponent(MyComp); const fixture = TestBed.createComponent(MyComp);
const dir = fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir; const dir =
fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir;
fixture.detectChanges(); fixture.detectChanges();
expect(dir.setterCalls).toEqual({'a': null, 'b': 2}); expect(dir.setterCalls).toEqual({'a': null, 'b': 2});
@ -160,6 +162,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get(token)).toEqual(tokenValue); expect(injector.get(token)).toEqual(tokenValue);
}); });
fixmeIvy('FW-646: Directive providers don\'t support primitive types as DI tokens') &&
it('should support providers with string token with a `.` in it', () => { it('should support providers with string token with a `.` in it', () => {
const token = 'a.b'; const token = 'a.b';
const tokenValue = 1; const tokenValue = 1;
@ -188,6 +191,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(injector.get(token2)).toEqual(tokenValue2); expect(injector.get(token2)).toEqual(tokenValue2);
}); });
fixmeIvy('FW-646: Directive providers don\'t support primitive types as DI tokens') &&
it('should support providers that have a `name` property with a number value', () => { it('should support providers that have a `name` property with a number value', () => {
class TestClass { class TestClass {
constructor(public name: number) {} constructor(public name: number) {}
@ -333,7 +337,7 @@ function declareTests(config?: {useJit: boolean}) {
expect(fixture.debugElement.childNodes.length).toBe(0); expect(fixture.debugElement.childNodes.length).toBe(0);
}); });
it('should allow empty embedded templates', () => { fixmeIvy('unknown') && it('should allow empty embedded templates', () => {
@Component({template: '<ng-template [ngIf]="true"></ng-template>'}) @Component({template: '<ng-template [ngIf]="true"></ng-template>'})
class MyComp { class MyComp {
} }
@ -350,7 +354,9 @@ function declareTests(config?: {useJit: boolean}) {
}); });
}); });
it('should support @ContentChild and @Input on the same property for static queries', () => { fixmeIvy('unknown') &&
it('should support @ContentChild and @Input on the same property for static queries',
() => {
@Directive({selector: 'test'}) @Directive({selector: 'test'})
class Test { class Test {
// TODO(issue/24571): remove '!'. // TODO(issue/24571): remove '!'.

View File

@ -16,9 +16,8 @@ import {fixmeIvy} from '@angular/private/testing';
if (ivyEnabled) { if (ivyEnabled) {
fixmeIvy('unknown') && describe('ivy', () => { declareTests(); }); fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
} else { } else {
fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); }); describe('jit', () => { declareTests({useJit: true}); });
describe('no jit', () => { declareTests({useJit: false}); });
fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
} }
} }