`;
@@ -130,19 +134,20 @@ function declareTests(config?: {useJit: boolean}) {
expect(dir.text).toEqual('container');
});
- it('should contain all direct child directives in a (content dom)', () => {
- const template =
- '';
- TestBed.overrideComponent(MyComp, {set: {template}});
- const fixture = TestBed.createComponent(MyComp);
+ fixmeIvy('unknown') &&
+ it('should contain all direct child directives in a (content dom)', () => {
+ const template =
+ '';
+ TestBed.overrideComponent(MyComp, {set: {template}});
+ const fixture = TestBed.createComponent(MyComp);
- fixture.detectChanges();
- const q = fixture.debugElement.children[0].references !['q'];
- fixture.detectChanges();
+ fixture.detectChanges();
+ const q = fixture.debugElement.children[0].references !['q'];
+ fixture.detectChanges();
- expect(q.textDirChildren.length).toEqual(1);
- expect(q.numberOfChildrenAfterContentInit).toEqual(1);
- });
+ expect(q.textDirChildren.length).toEqual(1);
+ expect(q.numberOfChildrenAfterContentInit).toEqual(1);
+ });
it('should contain all child directives in a (view dom)', () => {
const template = '';
diff --git a/packages/core/test/linker/ng_module_integration_spec.ts b/packages/core/test/linker/ng_module_integration_spec.ts
index 46cfdba52d..4ae6555c26 100644
--- a/packages/core/test/linker/ng_module_integration_spec.ts
+++ b/packages/core/test/linker/ng_module_integration_spec.ts
@@ -100,11 +100,10 @@ class DummyConsole implements Console {
{
if (ivyEnabled) {
- fixmeIvy('unknown') && describe('ivy', () => { declareTests(); });
+ describe('ivy', () => { declareTests(); });
} else {
- fixmeIvy('unknown') && describe('jit', () => { declareTests({useJit: true}); });
-
- fixmeIvy('unknown') && describe('no jit', () => { declareTests({useJit: false}); });
+ describe('jit', () => { declareTests({useJit: true}); });
+ describe('no jit', () => { declareTests({useJit: false}); });
}
}
@@ -144,124 +143,134 @@ function declareTests(config?: {useJit: boolean}) {
}
describe('errors', () => {
- it('should error when exporting a directive that was neither declared nor imported', () => {
- @NgModule({exports: [SomeDirective]})
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should error when exporting a directive that was neither declared nor imported', () => {
+ @NgModule({exports: [SomeDirective]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule))
- .toThrowError(
- `Can't export directive ${stringify(SomeDirective)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
- });
+ expect(() => createModule(SomeModule))
+ .toThrowError(
+ `Can't export directive ${stringify(SomeDirective)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
+ });
- it('should error when exporting a pipe that was neither declared nor imported', () => {
- @NgModule({exports: [SomePipe]})
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should error when exporting a pipe that was neither declared nor imported', () => {
+ @NgModule({exports: [SomePipe]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule))
- .toThrowError(
- `Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
- });
+ expect(() => createModule(SomeModule))
+ .toThrowError(
+ `Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
+ });
- it('should error if a directive is declared in more than 1 module', () => {
- @NgModule({declarations: [SomeDirective]})
- class Module1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should error if a directive is declared in more than 1 module', () => {
+ @NgModule({declarations: [SomeDirective]})
+ class Module1 {
+ }
- @NgModule({declarations: [SomeDirective]})
- class Module2 {
- }
+ @NgModule({declarations: [SomeDirective]})
+ class Module2 {
+ }
- createModule(Module1);
+ createModule(Module1);
- expect(() => createModule(Module2))
- .toThrowError(
- `Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
- `Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${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)}.`);
- });
+ expect(() => createModule(Module2))
+ .toThrowError(
+ `Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
+ `Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${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)}.`);
+ });
- 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]})
- class Module1 {
- }
+ 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',
+ () => {
+ @NgModule({declarations: [SomeDirective], exports: [SomeDirective]})
+ class Module1 {
+ }
- @NgModule({declarations: [SomeDirective], imports: [Module1]})
- class Module2 {
- }
+ @NgModule({declarations: [SomeDirective], imports: [Module1]})
+ class Module2 {
+ }
- expect(() => createModule(Module2))
- .toThrowError(
- `Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
- `Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${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)}.`);
- });
+ expect(() => createModule(Module2))
+ .toThrowError(
+ `Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
+ `Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${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)}.`);
+ });
- it('should error if a pipe is declared in more than 1 module', () => {
- @NgModule({declarations: [SomePipe]})
- class Module1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should error if a pipe is declared in more than 1 module', () => {
+ @NgModule({declarations: [SomePipe]})
+ class Module1 {
+ }
- @NgModule({declarations: [SomePipe]})
- class Module2 {
- }
+ @NgModule({declarations: [SomePipe]})
+ class Module2 {
+ }
- createModule(Module1);
+ createModule(Module1);
- expect(() => createModule(Module2))
- .toThrowError(
- `Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
- `Please consider moving ${stringify(SomePipe)} to a higher module that imports ${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)}.`);
- });
+ expect(() => createModule(Module2))
+ .toThrowError(
+ `Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
+ `Please consider moving ${stringify(SomePipe)} to a higher module that imports ${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)}.`);
+ });
- 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]})
- class Module1 {
- }
+ 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',
+ () => {
+ @NgModule({declarations: [SomePipe], exports: [SomePipe]})
+ class Module1 {
+ }
- @NgModule({declarations: [SomePipe], imports: [Module1]})
- class Module2 {
- }
+ @NgModule({declarations: [SomePipe], imports: [Module1]})
+ class Module2 {
+ }
- expect(() => createModule(Module2))
- .toThrowError(
- `Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
- `Please consider moving ${stringify(SomePipe)} to a higher module that imports ${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)}.`);
- });
+ expect(() => createModule(Module2))
+ .toThrowError(
+ `Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
+ `Please consider moving ${stringify(SomePipe)} to a higher module that imports ${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)}.`);
+ });
});
describe('schemas', () => {
- it('should error on unknown bound properties on custom elements by default', () => {
- @Component({template: ''})
- class ComponentUsingInvalidProperty {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should error on unknown bound properties on custom elements by default', () => {
+ @Component({template: ''})
+ class ComponentUsingInvalidProperty {
+ }
- @NgModule({declarations: [ComponentUsingInvalidProperty]})
- class SomeModule {
- }
+ @NgModule({declarations: [ComponentUsingInvalidProperty]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule)).toThrowError(/Can't bind to 'someUnknownProp'/);
- });
+ expect(() => createModule(SomeModule)).toThrowError(/Can't bind to 'someUnknownProp'/);
+ });
- it('should not error on unknown bound properties on custom elements when using the CUSTOM_ELEMENTS_SCHEMA',
- () => {
- @Component({template: ''})
- class ComponentUsingInvalidProperty {
- }
+ 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',
+ () => {
+ @Component({template: ''})
+ class ComponentUsingInvalidProperty {
+ }
- @NgModule(
- {schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ComponentUsingInvalidProperty]})
- class SomeModule {
- }
+ @NgModule({
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
+ declarations: [ComponentUsingInvalidProperty]
+ })
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule)).not.toThrow();
- });
+ expect(() => createModule(SomeModule)).not.toThrow();
+ });
});
describe('id', () => {
@@ -275,332 +284,361 @@ function declareTests(config?: {useJit: boolean}) {
afterEach(() => clearModulesForTest());
- it('should register loaded modules', () => {
- createModule(SomeModule);
- const factory = getModuleFactory(token);
- expect(factory).toBeTruthy();
- expect(factory.moduleType).toBe(SomeModule);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should register loaded modules', () => {
+ createModule(SomeModule);
+ const factory = getModuleFactory(token);
+ expect(factory).toBeTruthy();
+ expect(factory.moduleType).toBe(SomeModule);
+ });
- it('should throw when registering a duplicate module', () => {
- createModule(SomeModule);
- expect(() => createModule(SomeOtherModule)).toThrowError(/Duplicate module registered/);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when registering a duplicate module', () => {
+ createModule(SomeModule);
+ expect(() => createModule(SomeOtherModule)).toThrowError(/Duplicate module registered/);
+ });
});
describe('entryComponents', () => {
- it('should create ComponentFactories in root modules', () => {
- @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create ComponentFactories in root modules', () => {
+ @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
+ class SomeModule {
+ }
- const ngModule = createModule(SomeModule);
- expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
- .toBe(SomeComp);
- expect(ngModule.injector.get(ComponentFactoryResolver)
- .resolveComponentFactory(SomeComp)
- .componentType)
- .toBe(SomeComp);
- });
+ const ngModule = createModule(SomeModule);
+ expect(
+ ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
+ .toBe(SomeComp);
+ expect(ngModule.injector.get(ComponentFactoryResolver)
+ .resolveComponentFactory(SomeComp)
+ .componentType)
+ .toBe(SomeComp);
+ });
- it('should throw if we cannot find a module associated with a module-level entryComponent', () => {
- @Component({template: ''})
- class SomeCompWithEntryComponents {
- }
+ 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: ''})
+ class SomeCompWithEntryComponents {
+ }
- @NgModule({declarations: [], entryComponents: [SomeCompWithEntryComponents]})
- class SomeModule {
- }
+ @NgModule({declarations: [], entryComponents: [SomeCompWithEntryComponents]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule))
- .toThrowError(
- 'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.');
- });
+ expect(() => createModule(SomeModule))
+ .toThrowError(
+ 'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.');
+ });
- it('should throw if we cannot find a module associated with a component-level entryComponent',
- () => {
- @Component({template: '', entryComponents: [SomeComp]})
- class SomeCompWithEntryComponents {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw if we cannot find a module associated with a component-level entryComponent',
+ () => {
+ @Component({template: '', entryComponents: [SomeComp]})
+ class SomeCompWithEntryComponents {
+ }
- @NgModule({declarations: [SomeCompWithEntryComponents]})
- class SomeModule {
- }
+ @NgModule({declarations: [SomeCompWithEntryComponents]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule))
- .toThrowError(
- 'Component SomeComp is not part of any NgModule or the module has not been imported into your module.');
- });
+ expect(() => createModule(SomeModule))
+ .toThrowError(
+ 'Component SomeComp is not part of any NgModule or the module has not been imported into your module.');
+ });
- it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => {
- @NgModule({
- declarations: [SomeComp],
- providers: [{
- provide: ANALYZE_FOR_ENTRY_COMPONENTS,
- multi: true,
- useValue: [{a: 'b', component: SomeComp}]
- }]
- })
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => {
+ @NgModule({
+ declarations: [SomeComp],
+ providers: [{
+ provide: ANALYZE_FOR_ENTRY_COMPONENTS,
+ multi: true,
+ useValue: [{a: 'b', component: SomeComp}]
+ }]
+ })
+ class SomeModule {
+ }
- const ngModule = createModule(SomeModule);
- expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
- .toBe(SomeComp);
- expect(ngModule.injector.get(ComponentFactoryResolver)
- .resolveComponentFactory(SomeComp)
- .componentType)
- .toBe(SomeComp);
- });
+ const ngModule = createModule(SomeModule);
+ expect(
+ ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
+ .toBe(SomeComp);
+ expect(ngModule.injector.get(ComponentFactoryResolver)
+ .resolveComponentFactory(SomeComp)
+ .componentType)
+ .toBe(SomeComp);
+ });
- it('should create ComponentFactories in imported modules', () => {
- @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create ComponentFactories in imported modules', () => {
+ @NgModule({declarations: [SomeComp], entryComponents: [SomeComp]})
+ class SomeImportedModule {
+ }
- @NgModule({imports: [SomeImportedModule]})
- class SomeModule {
- }
+ @NgModule({imports: [SomeImportedModule]})
+ class SomeModule {
+ }
- const ngModule = createModule(SomeModule);
- expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
- .toBe(SomeComp);
- expect(ngModule.injector.get(ComponentFactoryResolver)
- .resolveComponentFactory(SomeComp)
- .componentType)
- .toBe(SomeComp);
- });
+ const ngModule = createModule(SomeModule);
+ expect(
+ ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
+ .toBe(SomeComp);
+ expect(ngModule.injector.get(ComponentFactoryResolver)
+ .resolveComponentFactory(SomeComp)
+ .componentType)
+ .toBe(SomeComp);
+ });
- it('should create ComponentFactories if the component was imported', () => {
- @NgModule({declarations: [SomeComp], exports: [SomeComp]})
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create ComponentFactories if the component was imported', () => {
+ @NgModule({declarations: [SomeComp], exports: [SomeComp]})
+ class SomeImportedModule {
+ }
- @NgModule({imports: [SomeImportedModule], entryComponents: [SomeComp]})
- class SomeModule {
- }
+ @NgModule({imports: [SomeImportedModule], entryComponents: [SomeComp]})
+ class SomeModule {
+ }
- const ngModule = createModule(SomeModule);
- expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
- .toBe(SomeComp);
- expect(ngModule.injector.get(ComponentFactoryResolver)
- .resolveComponentFactory(SomeComp)
- .componentType)
- .toBe(SomeComp);
- });
+ const ngModule = createModule(SomeModule);
+ expect(
+ ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
+ .toBe(SomeComp);
+ expect(ngModule.injector.get(ComponentFactoryResolver)
+ .resolveComponentFactory(SomeComp)
+ .componentType)
+ .toBe(SomeComp);
+ });
});
describe('bootstrap components', () => {
- it('should create ComponentFactories', () => {
- @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create ComponentFactories', () => {
+ @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
+ class SomeModule {
+ }
- const ngModule = createModule(SomeModule);
- expect(ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
- .toBe(SomeComp);
- });
+ const ngModule = createModule(SomeModule);
+ expect(
+ ngModule.componentFactoryResolver.resolveComponentFactory(SomeComp) !.componentType)
+ .toBe(SomeComp);
+ });
- it('should store the ComponentFactories in the NgModuleInjector', () => {
- @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should store the ComponentFactories in the NgModuleInjector', () => {
+ @NgModule({declarations: [SomeComp], bootstrap: [SomeComp]})
+ class SomeModule {
+ }
- const ngModule = >createModule(SomeModule);
- expect(ngModule._bootstrapComponents.length).toBe(1);
- expect(ngModule._bootstrapComponents[0]).toBe(SomeComp);
- });
+ const ngModule = >createModule(SomeModule);
+ expect(ngModule._bootstrapComponents.length).toBe(1);
+ expect(ngModule._bootstrapComponents[0]).toBe(SomeComp);
+ });
});
describe('directives and pipes', () => {
describe('declarations', () => {
- it('should be supported in root modules', () => {
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should be supported in root modules', () => {
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should be supported in imported modules', () => {
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should be supported in imported modules', () => {
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeImportedModule {
+ }
- @NgModule({imports: [SomeImportedModule]})
- class SomeModule {
- }
+ @NgModule({imports: [SomeImportedModule]})
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should be supported in nested components', () => {
- @Component({
- selector: 'parent',
- template: '',
- })
- class ParentCompUsingModuleDirectiveAndPipe {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should be supported in nested components', () => {
+ @Component({
+ selector: 'parent',
+ template: '',
+ })
+ class ParentCompUsingModuleDirectiveAndPipe {
+ }
- @NgModule({
- declarations: [
- ParentCompUsingModuleDirectiveAndPipe, CompUsingModuleDirectiveAndPipe, SomeDirective,
- SomePipe
- ],
- entryComponents: [ParentCompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [
+ ParentCompUsingModuleDirectiveAndPipe, CompUsingModuleDirectiveAndPipe,
+ SomeDirective, SomePipe
+ ],
+ entryComponents: [ParentCompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(ParentCompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(ParentCompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
});
describe('import/export', () => {
- it('should support exported directives and pipes', () => {
- @NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support exported directives and pipes', () => {
+ @NgModule(
+ {declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe],
- imports: [SomeImportedModule],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe],
+ imports: [SomeImportedModule],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`',
- () => {
- @NgModule(
- {declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`',
+ () => {
+ @NgModule(
+ {declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe],
- imports: [{ngModule: SomeImportedModule}],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe],
+ imports: [{ngModule: SomeImportedModule}],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should support reexported modules', () => {
- @NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
- class SomeReexportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support reexported modules', () => {
+ @NgModule(
+ {declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
+ class SomeReexportedModule {
+ }
- @NgModule({exports: [SomeReexportedModule]})
- class SomeImportedModule {
- }
+ @NgModule({exports: [SomeReexportedModule]})
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe],
- imports: [SomeImportedModule],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe],
+ imports: [SomeImportedModule],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should support exporting individual directives of an imported module', () => {
- @NgModule({declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
- class SomeReexportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support exporting individual directives of an imported module', () => {
+ @NgModule(
+ {declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
+ class SomeReexportedModule {
+ }
- @NgModule({imports: [SomeReexportedModule], exports: [SomeDirective, SomePipe]})
- class SomeImportedModule {
- }
+ @NgModule({imports: [SomeReexportedModule], exports: [SomeDirective, SomePipe]})
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe],
- imports: [SomeImportedModule],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe],
+ imports: [SomeImportedModule],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
- compFixture.detectChanges();
- expect(compFixture.debugElement.children[0].properties['title'])
- .toBe('transformed someValue');
- });
+ const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
+ compFixture.detectChanges();
+ expect(compFixture.debugElement.children[0].properties['title'])
+ .toBe('transformed someValue');
+ });
- it('should not use non exported pipes of an imported module', () => {
- @NgModule({
- declarations: [SomePipe],
- })
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should not use non exported pipes of an imported module', () => {
+ @NgModule({
+ declarations: [SomePipe],
+ })
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe],
- imports: [SomeImportedModule],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe],
+ imports: [SomeImportedModule],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- expect(() => createComp(SomeComp, SomeModule))
- .toThrowError(/The pipe 'somePipe' could not be found/);
- });
+ expect(() => createComp(SomeComp, SomeModule))
+ .toThrowError(/The pipe 'somePipe' could not be found/);
+ });
- it('should not use non exported directives of an imported module', () => {
- @NgModule({
- declarations: [SomeDirective],
- })
- class SomeImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should not use non exported directives of an imported module', () => {
+ @NgModule({
+ declarations: [SomeDirective],
+ })
+ class SomeImportedModule {
+ }
- @NgModule({
- declarations: [CompUsingModuleDirectiveAndPipe, SomePipe],
- imports: [SomeImportedModule],
- entryComponents: [CompUsingModuleDirectiveAndPipe]
- })
- class SomeModule {
- }
+ @NgModule({
+ declarations: [CompUsingModuleDirectiveAndPipe, SomePipe],
+ imports: [SomeImportedModule],
+ entryComponents: [CompUsingModuleDirectiveAndPipe]
+ })
+ class SomeModule {
+ }
- expect(() => createComp(SomeComp, SomeModule)).toThrowError(/Can't bind to 'someDir'/);
- });
+ expect(() => createComp(SomeComp, SomeModule))
+ .toThrowError(/Can't bind to 'someDir'/);
+ });
});
});
@@ -619,43 +657,49 @@ function declareTests(config?: {useJit: boolean}) {
return createModule(SomeModule, parent).injector;
}
- it('should provide the module',
- () => { expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType); });
-
- it('should instantiate a class without dependencies', () => {
- const injector = createInjector([Engine]);
- const engine = injector.get(Engine);
-
- expect(engine).toBeAnInstanceOf(Engine);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should provide the module', () => {
+ expect(createInjector([]).get(moduleType)).toBeAnInstanceOf(moduleType);
});
- it('should resolve dependencies based on type information', () => {
- const injector = createInjector([Engine, Car]);
- const car = injector.get(Car);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should instantiate a class without dependencies', () => {
+ const injector = createInjector([Engine]);
+ const engine = injector.get(Engine);
- expect(car).toBeAnInstanceOf(Car);
- expect(car.engine).toBeAnInstanceOf(Engine);
- });
+ expect(engine).toBeAnInstanceOf(Engine);
+ });
- it('should resolve dependencies based on @Inject annotation', () => {
- const injector = createInjector([TurboEngine, Engine, CarWithInject]);
- const car = injector.get(CarWithInject);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should resolve dependencies based on type information', () => {
+ const injector = createInjector([Engine, Car]);
+ const car = injector.get(Car);
- expect(car).toBeAnInstanceOf(CarWithInject);
- expect(car.engine).toBeAnInstanceOf(TurboEngine);
- });
+ expect(car).toBeAnInstanceOf(Car);
+ expect(car.engine).toBeAnInstanceOf(Engine);
+ });
- it('should throw when no type and not @Inject (class case)', () => {
- expect(() => createInjector([NoAnnotations]))
- .toThrowError('Can\'t resolve all parameters for NoAnnotations: (?).');
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should resolve dependencies based on @Inject annotation', () => {
+ const injector = createInjector([TurboEngine, Engine, CarWithInject]);
+ const car = injector.get(CarWithInject);
- it('should throw when no type and not @Inject (factory case)', () => {
- expect(() => createInjector([{provide: 'someToken', useFactory: factoryFn}]))
- .toThrowError('Can\'t resolve all parameters for factoryFn: (?).');
- });
+ expect(car).toBeAnInstanceOf(CarWithInject);
+ expect(car.engine).toBeAnInstanceOf(TurboEngine);
+ });
- it('should cache instances', () => {
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when no type and not @Inject (class case)', () => {
+ expect(() => createInjector([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)', () => {
+ expect(() => createInjector([{provide: 'someToken', useFactory: factoryFn}]))
+ .toThrowError('Can\'t resolve all parameters for factoryFn: (?).');
+ });
+
+ fixmeIvy('FW-561: Runtime compiler is not loaded') && it('should cache instances', () => {
const injector = createInjector([Engine]);
const e1 = injector.get(Engine);
@@ -664,31 +708,33 @@ function declareTests(config?: {useJit: boolean}) {
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 engine = injector.get(Engine);
expect(engine).toEqual('fake engine');
});
- it('should provide to a factory', () => {
- function sportsCarFactory(e: Engine) { return new SportsCar(e); }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should provide to a factory', () => {
+ function sportsCarFactory(e: Engine) { return new SportsCar(e); }
- const injector =
- createInjector([Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
+ const injector = createInjector(
+ [Engine, {provide: Car, useFactory: sportsCarFactory, deps: [Engine]}]);
- const car = injector.get(Car);
- expect(car).toBeAnInstanceOf(SportsCar);
- expect(car.engine).toBeAnInstanceOf(Engine);
- });
+ const car = injector.get(Car);
+ expect(car).toBeAnInstanceOf(SportsCar);
+ expect(car.engine).toBeAnInstanceOf(Engine);
+ });
- it('should supporting provider to null', () => {
- const injector = createInjector([{provide: Engine, useValue: null}]);
- const engine = injector.get(Engine);
- expect(engine).toBeNull();
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should supporting provider to null', () => {
+ const injector = createInjector([{provide: Engine, useValue: null}]);
+ const engine = injector.get(Engine);
+ 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([
Engine, {provide: SportsCar, useClass: SportsCar},
{provide: Car, useExisting: SportsCar}
@@ -700,97 +746,109 @@ function declareTests(config?: {useJit: boolean}) {
expect(car).toBe(sportsCar);
});
- it('should support multiProviders', () => {
- const injector = createInjector([
- Engine, {provide: CARS, useClass: SportsCar, multi: true},
- {provide: CARS, useClass: CarWithOptionalEngine, multi: true}
- ]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support multiProviders', () => {
+ const injector = createInjector([
+ Engine, {provide: CARS, useClass: SportsCar, multi: true},
+ {provide: CARS, useClass: CarWithOptionalEngine, multi: true}
+ ]);
- const cars = injector.get(CARS);
- expect(cars.length).toEqual(2);
- expect(cars[0]).toBeAnInstanceOf(SportsCar);
- expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
- });
+ const cars = injector.get(CARS);
+ expect(cars.length).toEqual(2);
+ expect(cars[0]).toBeAnInstanceOf(SportsCar);
+ expect(cars[1]).toBeAnInstanceOf(CarWithOptionalEngine);
+ });
- it('should support multiProviders that are created using useExisting', () => {
- const injector = createInjector(
- [Engine, SportsCar, {provide: CARS, useExisting: SportsCar, multi: true}]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support multiProviders that are created using useExisting', () => {
+ const injector = createInjector(
+ [Engine, SportsCar, {provide: CARS, useExisting: SportsCar, multi: true}]);
- const cars = injector.get(CARS);
- expect(cars.length).toEqual(1);
- expect(cars[0]).toBe(injector.get(SportsCar));
- });
+ const cars = injector.get(CARS);
+ expect(cars.length).toEqual(1);
+ expect(cars[0]).toBe(injector.get(SportsCar));
+ });
- it('should throw when the aliased provider does not exist', () => {
- const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
- const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
- expect(() => injector.get('car')).toThrowError(e);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when the aliased provider does not exist', () => {
+ const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
+ const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
+ expect(() => injector.get('car')).toThrowError(e);
+ });
- it('should handle forwardRef in useExisting', () => {
- const injector = createInjector([
- {provide: 'originalEngine', useClass: forwardRef(() => Engine)},
- {provide: 'aliasedEngine', useExisting: forwardRef(() => 'originalEngine')}
- ]);
- expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should handle forwardRef in useExisting', () => {
+ const injector = createInjector([
+ {provide: 'originalEngine', useClass: forwardRef(() => Engine)},
+ {provide: 'aliasedEngine', useExisting: forwardRef(() => 'originalEngine')}
+ ]);
+ expect(injector.get('aliasedEngine')).toBeAnInstanceOf(Engine);
+ });
- it('should support overriding factory dependencies', () => {
- const injector = createInjector(
- [Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support overriding factory dependencies', () => {
+ const injector = createInjector([
+ Engine, {provide: Car, useFactory: (e: Engine) => new SportsCar(e), deps: [Engine]}
+ ]);
- const car = injector.get(Car);
- expect(car).toBeAnInstanceOf(SportsCar);
- expect(car.engine).toBeAnInstanceOf(Engine);
- });
+ const car = injector.get(Car);
+ expect(car).toBeAnInstanceOf(SportsCar);
+ expect(car.engine).toBeAnInstanceOf(Engine);
+ });
- it('should support optional dependencies', () => {
- const injector = createInjector([CarWithOptionalEngine]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support optional dependencies', () => {
+ const injector = createInjector([CarWithOptionalEngine]);
- const car = injector.get(CarWithOptionalEngine);
- expect(car.engine).toBeNull();
- });
+ const car = injector.get(CarWithOptionalEngine);
+ expect(car.engine).toBeNull();
+ });
- it('should flatten passed-in providers', () => {
- const injector = createInjector([[[Engine, Car]]]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should flatten passed-in providers', () => {
+ const injector = createInjector([[[Engine, Car]]]);
- const car = injector.get(Car);
- expect(car).toBeAnInstanceOf(Car);
- });
+ const car = injector.get(Car);
+ expect(car).toBeAnInstanceOf(Car);
+ });
- it('should use the last provider when there are multiple providers for same token', () => {
- const injector = createInjector(
- [{provide: Engine, useClass: Engine}, {provide: Engine, useClass: TurboEngine}]);
+ 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(
+ [{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'}]);
expect(injector.get('token')).toEqual('value');
});
- it('should throw when given invalid providers', () => {
- expect(() => createInjector(['blah']))
- .toThrowError(
- `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 invalid providers', () => {
+ expect(() => createInjector(['blah']))
+ .toThrowError(
+ `Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?blah?]`);
+ });
- it('should throw when given blank providers', () => {
- expect(() => createInjector([null, {provide: 'token', useValue: 'value'}]))
- .toThrowError(
- `Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?null?, ...]`);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when given blank providers', () => {
+ expect(() => createInjector([null, {provide: 'token', useValue: 'value'}]))
+ .toThrowError(
+ `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 child = createInjector([], parent);
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;
const injector = createInjector([{
@@ -808,179 +866,193 @@ function declareTests(config?: {useJit: boolean}) {
describe('injecting lazy providers into an eager provider via Injector.get', () => {
- it('should inject providers that were declared before it', () => {
- @NgModule({
- providers: [
- {provide: 'lazy', useFactory: () => 'lazyValue'},
- {
- provide: 'eager',
- useFactory: (i: Injector) => `eagerValue: ${i.get('lazy')}`,
- deps: [Injector]
- },
- ]
- })
- class MyModule {
- // NgModule is eager, which makes all of its deps eager
- constructor(@Inject('eager') eager: any) {}
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should inject providers that were declared before it', () => {
+ @NgModule({
+ providers: [
+ {provide: 'lazy', useFactory: () => 'lazyValue'},
+ {
+ provide: 'eager',
+ useFactory: (i: Injector) => `eagerValue: ${i.get('lazy')}`,
+ deps: [Injector]
+ },
+ ]
+ })
+ class MyModule {
+ // NgModule is eager, which makes all of its deps eager
+ constructor(@Inject('eager') eager: any) {}
+ }
- expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue');
- });
+ expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue');
+ });
- it('should inject providers that were declared after it', () => {
- @NgModule({
- providers: [
- {
- provide: 'eager',
- useFactory: (i: Injector) => `eagerValue: ${i.get('lazy')}`,
- deps: [Injector]
- },
- {provide: 'lazy', useFactory: () => 'lazyValue'},
- ]
- })
- class MyModule {
- // NgModule is eager, which makes all of its deps eager
- constructor(@Inject('eager') eager: any) {}
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should inject providers that were declared after it', () => {
+ @NgModule({
+ providers: [
+ {
+ provide: 'eager',
+ useFactory: (i: Injector) => `eagerValue: ${i.get('lazy')}`,
+ deps: [Injector]
+ },
+ {provide: 'lazy', useFactory: () => 'lazyValue'},
+ ]
+ })
+ class MyModule {
+ // NgModule is eager, which makes all of its deps eager
+ constructor(@Inject('eager') eager: any) {}
+ }
- expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue');
- });
+ expect(createModule(MyModule).injector.get('eager')).toBe('eagerValue: lazyValue');
+ });
});
describe('injecting eager providers into an eager provider via Injector.get', () => {
- it('should inject providers that were declared before it', () => {
- @NgModule({
- providers: [
- {provide: 'eager1', useFactory: () => 'v1'},
- {
- provide: 'eager2',
- useFactory: (i: Injector) => `v2: ${i.get('eager1')}`,
- deps: [Injector]
- },
- ]
- })
- class MyModule {
- // NgModule is eager, which makes all of its deps eager
- constructor(@Inject('eager1') eager1: any, @Inject('eager2') eager2: any) {}
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should inject providers that were declared before it', () => {
+ @NgModule({
+ providers: [
+ {provide: 'eager1', useFactory: () => 'v1'},
+ {
+ provide: 'eager2',
+ useFactory: (i: Injector) => `v2: ${i.get('eager1')}`,
+ deps: [Injector]
+ },
+ ]
+ })
+ class MyModule {
+ // NgModule is eager, which makes all of its deps eager
+ constructor(@Inject('eager1') eager1: any, @Inject('eager2') eager2: any) {}
+ }
- expect(createModule(MyModule).injector.get('eager2')).toBe('v2: v1');
- });
+ expect(createModule(MyModule).injector.get('eager2')).toBe('v2: v1');
+ });
- it('should inject providers that were declared after it', () => {
- @NgModule({
- providers: [
- {
- provide: 'eager1',
- useFactory: (i: Injector) => `v1: ${i.get('eager2')}`,
- deps: [Injector]
- },
- {provide: 'eager2', useFactory: () => 'v2'},
- ]
- })
- class MyModule {
- // NgModule is eager, which makes all of its deps eager
- constructor(@Inject('eager1') eager1: any, @Inject('eager2') eager2: any) {}
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should inject providers that were declared after it', () => {
+ @NgModule({
+ providers: [
+ {
+ provide: 'eager1',
+ useFactory: (i: Injector) => `v1: ${i.get('eager2')}`,
+ deps: [Injector]
+ },
+ {provide: 'eager2', useFactory: () => 'v2'},
+ ]
+ })
+ class MyModule {
+ // NgModule is eager, which makes all of its deps eager
+ constructor(@Inject('eager1') eager1: any, @Inject('eager2') eager2: any) {}
+ }
- expect(createModule(MyModule).injector.get('eager1')).toBe('v1: v2');
- });
+ expect(createModule(MyModule).injector.get('eager1')).toBe('v1: v2');
+ });
- it('eager providers should get initialized only once', () => {
- @Injectable()
- class MyService1 {
- public innerService: MyService2;
- constructor(injector: Injector) {
- // Create MyService2 before it it's initialized by TestModule.
- this.innerService = injector.get(MyService2);
- }
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('eager providers should get initialized only once', () => {
+ @Injectable()
+ class MyService1 {
+ public innerService: MyService2;
+ constructor(injector: Injector) {
+ // Create MyService2 before it it's initialized by TestModule.
+ this.innerService = injector.get(MyService2);
+ }
+ }
- @Injectable()
- class MyService2 {
- constructor() {}
- }
+ @Injectable()
+ class MyService2 {
+ constructor() {}
+ }
- @NgModule({
- providers: [MyService1, MyService2],
- })
- class TestModule {
- constructor(public service1: MyService1, public service2: MyService2) {}
- }
+ @NgModule({
+ providers: [MyService1, MyService2],
+ })
+ class TestModule {
+ constructor(public service1: MyService1, public service2: MyService2) {}
+ }
- const moduleRef = createModule(TestModule, injector);
- const module = moduleRef.instance;
+ const moduleRef = createModule(TestModule, injector);
+ const module = moduleRef.instance;
- // MyService2 should not get initialized twice.
- expect(module.service1.innerService).toBe(module.service2);
- });
+ // MyService2 should not get initialized twice.
+ expect(module.service1.innerService).toBe(module.service2);
+ });
});
- it('should throw when no provider defined', () => {
- const injector = createInjector([]);
- expect(() => injector.get('NonExisting'))
- .toThrowError('NullInjectorError: No provider for NonExisting!');
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when no provider defined', () => {
+ const injector = createInjector([]);
+ expect(() => injector.get('NonExisting'))
+ .toThrowError('NullInjectorError: No provider for NonExisting!');
+ });
- it('should throw when trying to instantiate a cyclic dependency', () => {
- expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}]))
- .toThrowError(/Cannot instantiate cyclic dependency! Car/g);
- });
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should throw when trying to instantiate a cyclic dependency', () => {
+ expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}]))
+ .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}]);
expect(injector.get('null')).toBe(null);
});
describe('child', () => {
- it('should load instances from parent injector', () => {
- const parent = createInjector([Engine]);
- const child = createInjector([], parent);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should load instances from parent injector', () => {
+ const parent = createInjector([Engine]);
+ const child = createInjector([], parent);
- const engineFromParent = parent.get(Engine);
- const engineFromChild = child.get(Engine);
+ const engineFromParent = parent.get(Engine);
+ const engineFromChild = child.get(Engine);
- expect(engineFromChild).toBe(engineFromParent);
- });
+ expect(engineFromChild).toBe(engineFromParent);
+ });
- it('should not use the child providers when resolving the dependencies of a parent provider',
- () => {
- const parent = createInjector([Car, Engine]);
- const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should not use the child providers when resolving the dependencies of a parent provider',
+ () => {
+ const parent = createInjector([Car, Engine]);
+ const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
- const carFromChild = child.get(Car);
- expect(carFromChild.engine).toBeAnInstanceOf(Engine);
- });
+ const carFromChild = child.get(Car);
+ expect(carFromChild.engine).toBeAnInstanceOf(Engine);
+ });
- it('should create new instance in a child injector', () => {
- const parent = createInjector([Engine]);
- const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should create new instance in a child injector', () => {
+ const parent = createInjector([Engine]);
+ const child = createInjector([{provide: Engine, useClass: TurboEngine}], parent);
- const engineFromParent = parent.get(Engine);
- const engineFromChild = child.get(Engine);
+ const engineFromParent = parent.get(Engine);
+ const engineFromChild = child.get(Engine);
- expect(engineFromParent).not.toBe(engineFromChild);
- expect(engineFromChild).toBeAnInstanceOf(TurboEngine);
- });
+ expect(engineFromParent).not.toBe(engineFromChild);
+ expect(engineFromChild).toBeAnInstanceOf(TurboEngine);
+ });
});
describe('depedency resolution', () => {
describe('@Self()', () => {
- it('should return a dependency from self', () => {
- const inj = createInjector([
- Engine,
- {provide: Car, useFactory: (e: Engine) => new Car(e), deps: [[Engine, new Self()]]}
- ]);
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should return a dependency from self', () => {
+ const inj = createInjector([
+ Engine, {
+ provide: Car,
+ useFactory: (e: Engine) => new Car(e),
+ deps: [[Engine, new Self()]]
+ }
+ ]);
- expect(inj.get(Car)).toBeAnInstanceOf(Car);
- });
+ expect(inj.get(Car)).toBeAnInstanceOf(Car);
+ });
});
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 child = createInjector(
[
@@ -995,7 +1067,7 @@ function declareTests(config?: {useJit: boolean}) {
});
describe('lifecycle', () => {
- it('should instantiate modules eagerly', () => {
+ fixmeIvy('unknown') && it('should instantiate modules eagerly', () => {
let created = false;
@NgModule()
@@ -1012,325 +1084,347 @@ function declareTests(config?: {useJit: boolean}) {
expect(created).toBe(true);
});
- it('should instantiate providers that are not used by a module lazily', () => {
- let created = false;
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should instantiate providers that are not used by a module lazily', () => {
+ let created = false;
- createInjector([{
- provide: 'someToken',
- useFactory: () => {
- created = true;
- return true;
- }
- }]);
+ createInjector([{
+ provide: 'someToken',
+ useFactory: () => {
+ created = true;
+ return true;
+ }
+ }]);
- expect(created).toBe(false);
- });
+ expect(created).toBe(false);
+ });
- it('should support ngOnDestroy on any provider', () => {
- let destroyed = false;
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support ngOnDestroy on any provider', () => {
+ let destroyed = false;
- class SomeInjectable {
- ngOnDestroy() { destroyed = true; }
- }
+ class SomeInjectable {
+ ngOnDestroy() { destroyed = true; }
+ }
- @NgModule({providers: [SomeInjectable]})
- class SomeModule {
- // Inject SomeInjectable to make it eager...
- constructor(i: SomeInjectable) {}
- }
+ @NgModule({providers: [SomeInjectable]})
+ class SomeModule {
+ // Inject SomeInjectable to make it eager...
+ constructor(i: SomeInjectable) {}
+ }
- const moduleRef = createModule(SomeModule);
- expect(destroyed).toBe(false);
- moduleRef.destroy();
- expect(destroyed).toBe(true);
- });
+ const moduleRef = createModule(SomeModule);
+ expect(destroyed).toBe(false);
+ moduleRef.destroy();
+ expect(destroyed).toBe(true);
+ });
- it('should support ngOnDestroy for lazy providers', () => {
- let created = false;
- let destroyed = false;
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should support ngOnDestroy for lazy providers', () => {
+ let created = false;
+ let destroyed = false;
- class SomeInjectable {
- constructor() { created = true; }
- ngOnDestroy() { destroyed = true; }
- }
+ class SomeInjectable {
+ constructor() { created = true; }
+ ngOnDestroy() { destroyed = true; }
+ }
- @NgModule({providers: [SomeInjectable]})
- class SomeModule {
- }
+ @NgModule({providers: [SomeInjectable]})
+ class SomeModule {
+ }
- let moduleRef = createModule(SomeModule);
- expect(created).toBe(false);
- expect(destroyed).toBe(false);
+ let moduleRef = createModule(SomeModule);
+ expect(created).toBe(false);
+ expect(destroyed).toBe(false);
- // no error if the provider was not yet created
- moduleRef.destroy();
- expect(created).toBe(false);
- expect(destroyed).toBe(false);
+ // no error if the provider was not yet created
+ moduleRef.destroy();
+ expect(created).toBe(false);
+ expect(destroyed).toBe(false);
- moduleRef = createModule(SomeModule);
- moduleRef.injector.get(SomeInjectable);
- expect(created).toBe(true);
- moduleRef.destroy();
- expect(destroyed).toBe(true);
- });
+ moduleRef = createModule(SomeModule);
+ moduleRef.injector.get(SomeInjectable);
+ expect(created).toBe(true);
+ moduleRef.destroy();
+ expect(destroyed).toBe(true);
+ });
});
describe('imported and exported modules', () => {
- it('should add the providers of imported modules', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
- class ImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should add the providers of imported modules', () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
+ class ImportedModule {
+ }
- @NgModule({imports: [ImportedModule]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModule]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
+ const injector = createModule(SomeModule).injector;
- expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
- expect(injector.get(ImportedModule)).toBeAnInstanceOf(ImportedModule);
- expect(injector.get('token1')).toBe('imported');
- });
+ expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
+ expect(injector.get(ImportedModule)).toBeAnInstanceOf(ImportedModule);
+ expect(injector.get('token1')).toBe('imported');
+ });
- it('should add the providers of imported ModuleWithProviders', () => {
- @NgModule()
- class ImportedModule {
- }
+ fixmeIvy('unknown') &&
+ it('should add the providers of imported ModuleWithProviders', () => {
+ @NgModule()
+ class ImportedModule {
+ }
- @NgModule({
- imports: [
- {ngModule: ImportedModule, providers: [{provide: 'token1', useValue: 'imported'}]}
- ]
- })
- class SomeModule {
- }
+ @NgModule({
+ imports: [{
+ ngModule: ImportedModule,
+ providers: [{provide: 'token1', useValue: 'imported'}]
+ }]
+ })
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
+ const injector = createModule(SomeModule).injector;
- expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
- expect(injector.get(ImportedModule)).toBeAnInstanceOf(ImportedModule);
- expect(injector.get('token1')).toBe('imported');
- });
+ expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
+ expect(injector.get(ImportedModule)).toBeAnInstanceOf(ImportedModule);
+ expect(injector.get('token1')).toBe('imported');
+ });
- it('should overwrite the providers of imported modules', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
- class ImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should overwrite the providers of imported modules', () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
+ class ImportedModule {
+ }
- @NgModule(
- {providers: [{provide: 'token1', useValue: 'direct'}], imports: [ImportedModule]})
- class SomeModule {
- }
+ @NgModule(
+ {providers: [{provide: 'token1', useValue: 'direct'}], imports: [ImportedModule]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('direct');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('direct');
+ });
- it('should overwrite the providers of imported ModuleWithProviders', () => {
- @NgModule()
- class ImportedModule {
- }
+ fixmeIvy('unknown') &&
+ it('should overwrite the providers of imported ModuleWithProviders', () => {
+ @NgModule()
+ class ImportedModule {
+ }
- @NgModule({
- providers: [{provide: 'token1', useValue: 'direct'}],
- imports: [
- {ngModule: ImportedModule, providers: [{provide: 'token1', useValue: 'imported'}]}
- ]
- })
- class SomeModule {
- }
+ @NgModule({
+ providers: [{provide: 'token1', useValue: 'direct'}],
+ imports: [{
+ ngModule: ImportedModule,
+ providers: [{provide: 'token1', useValue: 'imported'}]
+ }]
+ })
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('direct');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('direct');
+ });
- it('should overwrite the providers of imported modules on the second import level', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
- class ImportedModuleLevel2 {
- }
+ 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'}]})
+ class ImportedModuleLevel2 {
+ }
- @NgModule({
- providers: [{provide: 'token1', useValue: 'direct'}],
- imports: [ImportedModuleLevel2]
- })
- class ImportedModuleLevel1 {
- }
+ @NgModule({
+ providers: [{provide: 'token1', useValue: 'direct'}],
+ imports: [ImportedModuleLevel2]
+ })
+ class ImportedModuleLevel1 {
+ }
- @NgModule({imports: [ImportedModuleLevel1]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModuleLevel1]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('direct');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('direct');
+ });
- it('should add the providers of exported modules', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
- class ExportedValue {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should add the providers of exported modules', () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
+ class ExportedValue {
+ }
- @NgModule({exports: [ExportedValue]})
- class SomeModule {
- }
+ @NgModule({exports: [ExportedValue]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
+ const injector = createModule(SomeModule).injector;
- expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
- expect(injector.get(ExportedValue)).toBeAnInstanceOf(ExportedValue);
- expect(injector.get('token1')).toBe('exported');
- });
+ expect(injector.get(SomeModule)).toBeAnInstanceOf(SomeModule);
+ expect(injector.get(ExportedValue)).toBeAnInstanceOf(ExportedValue);
+ expect(injector.get('token1')).toBe('exported');
+ });
- it('should overwrite the providers of exported modules', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
- class ExportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should overwrite the providers of exported modules', () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
+ class ExportedModule {
+ }
- @NgModule(
- {providers: [{provide: 'token1', useValue: 'direct'}], exports: [ExportedModule]})
- class SomeModule {
- }
+ @NgModule(
+ {providers: [{provide: 'token1', useValue: 'direct'}], exports: [ExportedModule]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('direct');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('direct');
+ });
- it('should overwrite the providers of imported modules by following imported modules',
- () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
- class ImportedModule1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should overwrite the providers of imported modules by following imported modules',
+ () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
+ class ImportedModule1 {
+ }
- @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
- class ImportedModule2 {
- }
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
+ class ImportedModule2 {
+ }
- @NgModule({imports: [ImportedModule1, ImportedModule2]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModule1, ImportedModule2]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('imported2');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('imported2');
+ });
- it('should overwrite the providers of exported modules by following exported modules',
- () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'exported1'}]})
- class ExportedModule1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should overwrite the providers of exported modules by following exported modules',
+ () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'exported1'}]})
+ class ExportedModule1 {
+ }
- @NgModule({providers: [{provide: 'token1', useValue: 'exported2'}]})
- class ExportedModule2 {
- }
+ @NgModule({providers: [{provide: 'token1', useValue: 'exported2'}]})
+ class ExportedModule2 {
+ }
- @NgModule({exports: [ExportedModule1, ExportedModule2]})
- class SomeModule {
- }
+ @NgModule({exports: [ExportedModule1, ExportedModule2]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('exported2');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('exported2');
+ });
- it('should overwrite the providers of imported modules by exported modules', () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
- class ImportedModule {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should overwrite the providers of imported modules by exported modules', () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported'}]})
+ class ImportedModule {
+ }
- @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
- class ExportedModule {
- }
+ @NgModule({providers: [{provide: 'token1', useValue: 'exported'}]})
+ class ExportedModule {
+ }
- @NgModule({imports: [ImportedModule], exports: [ExportedModule]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModule], exports: [ExportedModule]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('exported');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('exported');
+ });
- it('should not overwrite the providers if a module was already used on the same level',
- () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
- class ImportedModule1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should not overwrite the providers if a module was already used on the same level',
+ () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
+ class ImportedModule1 {
+ }
- @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
- class ImportedModule2 {
- }
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
+ class ImportedModule2 {
+ }
- @NgModule({imports: [ImportedModule1, ImportedModule2, ImportedModule1]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModule1, ImportedModule2, ImportedModule1]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('imported2');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('imported2');
+ });
- it('should not overwrite the providers if a module was already used on a child level',
- () => {
- @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
- class ImportedModule1 {
- }
+ fixmeIvy('FW-561: Runtime compiler is not loaded') &&
+ it('should not overwrite the providers if a module was already used on a child level',
+ () => {
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported1'}]})
+ class ImportedModule1 {
+ }
- @NgModule({imports: [ImportedModule1]})
- class ImportedModule3 {
- }
+ @NgModule({imports: [ImportedModule1]})
+ class ImportedModule3 {
+ }
- @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
- class ImportedModule2 {
- }
+ @NgModule({providers: [{provide: 'token1', useValue: 'imported2'}]})
+ class ImportedModule2 {
+ }
- @NgModule({imports: [ImportedModule3, ImportedModule2, ImportedModule1]})
- class SomeModule {
- }
+ @NgModule({imports: [ImportedModule3, ImportedModule2, ImportedModule1]})
+ class SomeModule {
+ }
- const injector = createModule(SomeModule).injector;
- expect(injector.get('token1')).toBe('imported2');
- });
+ const injector = createModule(SomeModule).injector;
+ expect(injector.get('token1')).toBe('imported2');
+ });
- it('should throw when given invalid providers in an imported ModuleWithProviders', () => {
- @NgModule()
- class ImportedModule1 {
- }
+ fixmeIvy('unknown') &&
+ it('should throw when given invalid providers in an imported ModuleWithProviders', () => {
+ @NgModule()
+ class ImportedModule1 {
+ }
- @NgModule({imports: [{ngModule: ImportedModule1, providers: ['broken']}]})
- class SomeModule {
- }
+ @NgModule({imports: [{ngModule: ImportedModule1, providers: ['broken']}]})
+ class SomeModule {
+ }
- expect(() => createModule(SomeModule).injector)
- .toThrowError(
- `Invalid provider for the NgModule 'ImportedModule1' - only instances of Provider and Type are allowed, got: [?broken?]`);
- });
+ expect(() => createModule(SomeModule).injector)
+ .toThrowError(
+ `Invalid provider for the NgModule 'ImportedModule1' - only instances of Provider and Type are allowed, got: [?broken?]`);
+ });
});
describe('tree shakable providers', () => {
- it('definition should not persist across NgModuleRef instances', () => {
- @NgModule()
- class SomeModule {
- }
+ fixmeIvy('unknown') &&
+ it('definition should not persist across NgModuleRef instances', () => {
+ @NgModule()
+ class SomeModule {
+ }
- class Bar {
- static ngInjectableDef: InjectableDef = defineInjectable({
- factory: () => new Bar(),
- providedIn: SomeModule,
+ class Bar {
+ static ngInjectableDef: InjectableDef = defineInjectable({
+ factory: () => new Bar(),
+ providedIn: SomeModule,
+ });
+ }
+
+ const factory = createModuleFactory(SomeModule);
+ const ngModuleRef1 = factory.create(null);
+
+ // Inject a tree shakeable provider token.
+ ngModuleRef1.injector.get(Bar);
+
+ // Tree Shakeable provider definition should get added to the NgModule data.
+ const providerDef1 =
+ (ngModuleRef1 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
+ expect(providerDef1).not.toBeUndefined();
+
+ // Instantiate the same module. The tree shakeable provider
+ // definition should not already be present.
+ const ngModuleRef2 = factory.create(null);
+ const providerDef2 =
+ (ngModuleRef2 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
+ expect(providerDef2).toBeUndefined();
});
- }
-
- const factory = createModuleFactory(SomeModule);
- const ngModuleRef1 = factory.create(null);
-
- // Inject a tree shakeable provider token.
- ngModuleRef1.injector.get(Bar);
-
- // Tree Shakeable provider definition should get added to the NgModule data.
- const providerDef1 = (ngModuleRef1 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
- expect(providerDef1).not.toBeUndefined();
-
- // Instantiate the same module. The tree shakeable provider
- // definition should not already be present.
- const ngModuleRef2 = factory.create(null);
- const providerDef2 = (ngModuleRef2 as NgModuleData)._def.providersByKey[tokenKey(Bar)];
- expect(providerDef2).toBeUndefined();
- });
});
});
});
diff --git a/packages/core/test/linker/projection_integration_spec.ts b/packages/core/test/linker/projection_integration_spec.ts
index 2cb04d34ff..f7a58249b4 100644
--- a/packages/core/test/linker/projection_integration_spec.ts
+++ b/packages/core/test/linker/projection_integration_spec.ts
@@ -14,7 +14,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
import {fixmeIvy} from '@angular/private/testing';
{
- fixmeIvy('unknown') && describe('projection', () => {
+ describe('projection', () => {
beforeEach(() => TestBed.configureTestingModule({declarations: [MainComp, OtherComp, Simple]}));
it('should support simple components', () => {
@@ -82,7 +82,7 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('');
});
- it('should support multiple content tags', () => {
+ fixmeIvy('unknown') && it('should support multiple content tags', () => {
TestBed.configureTestingModule({declarations: [MultipleContentTagsComponent]});
TestBed.overrideComponent(MainComp, {
set: {
@@ -113,33 +113,34 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('(, BAC)');
});
- it('should redistribute direct child viewcontainers when the light dom changes', () => {
- TestBed.configureTestingModule(
- {declarations: [MultipleContentTagsComponent, ManualViewportDirective]});
- TestBed.overrideComponent(MainComp, {
- set: {
- template: '' +
- '
A1
' +
- '
B
' +
- ''
- }
- });
- const main = TestBed.createComponent(MainComp);
+ 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', () => {
+ TestBed.configureTestingModule(
+ {declarations: [MultipleContentTagsComponent, ManualViewportDirective]});
+ TestBed.overrideComponent(MainComp, {
+ set: {
+ template: '' +
+ '
' +
- ''
- }
- });
- const main = TestBed.createComponent(MainComp);
+ 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', () => {
+ TestBed.configureTestingModule({
+ declarations:
+ [InnerComponent, InnerInnerComponent, OuterComponent, ManualViewportDirective]
+ });
+ TestBed.overrideComponent(MainComp, {
+ set: {
+ template: '' +
+ '
A
' +
+ '
B
' +
+ '
C
' +
+ ''
+ }
+ });
+ const main = TestBed.createComponent(MainComp);
- const viewportDirective =
- main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0].injector.get(
- ManualViewportDirective);
+ const viewportDirective =
+ main.debugElement.queryAllNodes(By.directive(ManualViewportDirective))[0]
+ .injector.get(ManualViewportDirective);
- expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
- viewportDirective.show();
+ expect(main.nativeElement).toHaveText('OUTER(INNER(INNERINNER(,BC)))');
+ viewportDirective.show();
- 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(
{declarations: [ConditionalContentComponent, ManualViewportDirective]});
TestBed.overrideComponent(MainComp, {
@@ -237,37 +239,38 @@ import {fixmeIvy} from '@angular/private/testing';
expect(main.nativeElement).toHaveText('P,text');
});
- it('should support moving non projected light dom around', () => {
- let sourceDirective: ManualViewportDirective = undefined !;
+ fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
+ it('should support moving non projected light dom around', () => {
+ let sourceDirective: ManualViewportDirective = undefined !;
- @Directive({selector: '[manual]'})
- class ManualViewportDirective {
- constructor(public templateRef: TemplateRef