test(ivy): remove ngComponentOutlet example with a lazy-loaded NgModule (#29094)

PR Close #29094
This commit is contained in:
Pawel Kozlowski 2019-03-04 14:59:52 +01:00 committed by Andrew Kushnir
parent aa57bdbf90
commit 04cf4ef0c7
3 changed files with 23 additions and 81 deletions

View File

@ -60,10 +60,6 @@ import {ComponentFactoryResolver, ComponentRef, Directive, Injector, Input, NgMo
* A more complete example with additional options: * A more complete example with additional options:
* *
* {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'} * {@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
* A more complete example with ngModuleFactory:
*
* {@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'}
* *
* @publicApi * @publicApi
* @ngModule CommonModule * @ngModule CommonModule

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {fixmeIvy, modifiedInIvy} from '@angular/private/testing'; import {modifiedInIvy} from '@angular/private/testing';
import {$, ExpectedConditions, browser, by, element} from 'protractor'; import {$, ExpectedConditions, browser, by, element} from 'protractor';
import {verifyNoBrowserErrors} from '../../../../test-utils'; import {verifyNoBrowserErrors} from '../../../../test-utils';
@ -17,33 +17,24 @@ function waitForElement(selector: string) {
browser.wait(EC.presenceOf($(selector)), 20000); browser.wait(EC.presenceOf($(selector)), 20000);
} }
fixmeIvy('FW-1022: JitCompilerFactory creates incorrect compiler instance') describe('ngComponentOutlet', () => {
.describe('ngComponentOutlet', () => { const URL = '/ngComponentOutlet';
const URL = '/ngComponentOutlet'; afterEach(verifyNoBrowserErrors);
afterEach(verifyNoBrowserErrors);
describe('ng-component-outlet-example', () => { describe('ng-component-outlet-example', () => {
it('should render simple', () => { it('should render simple', () => {
browser.get(URL);
waitForElement('ng-component-outlet-simple-example');
expect(element.all(by.css('hello-world')).getText()).toEqual(['Hello World!']);
});
modifiedInIvy('Different behavior for projectableNodes in ViewContainerRef.createComponent')
.it('should render complete', () => {
browser.get(URL); browser.get(URL);
waitForElement('ng-component-outlet-simple-example'); waitForElement('ng-component-outlet-complete-example');
expect(element.all(by.css('hello-world')).getText()).toEqual(['Hello World!']); expect(element.all(by.css('complete-component')).getText()).toEqual([
}); 'Complete: AhojSvet!'
modifiedInIvy('Different behavior for projectableNodes in ViewContainerRef.createComponent')
.it('should render complete', () => {
browser.get(URL);
waitForElement('ng-component-outlet-complete-example');
expect(element.all(by.css('complete-component')).getText()).toEqual([
'Complete: AhojSvet!'
]);
});
it('should render other module', () => {
browser.get(URL);
waitForElement('ng-component-outlet-other-module-example');
expect(element.all(by.css('other-module-component')).getText()).toEqual([
'Other Module Component!'
]); ]);
}); });
}); });
}); });

View File

@ -6,11 +6,8 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {CommonModule} from '@angular/common'; import {Component, Injectable, Injector, NgModule} from '@angular/core';
import {COMPILER_OPTIONS, Compiler, CompilerFactory, Component, Injectable, Injector, NgModule, NgModuleFactory} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {JitCompilerFactory} from '@angular/platform-browser-dynamic';
// #docregion SimpleExample // #docregion SimpleExample
@ -63,65 +60,23 @@ export class NgTemplateOutletCompleteExample {
} }
// #enddocregion // #enddocregion
// #docregion NgModuleFactoryExample
@Component({selector: 'other-module-component', template: `Other Module Component!`})
export class OtherModuleComponent {
}
@Component({
selector: 'ng-component-outlet-other-module-example',
template: `
<ng-container *ngComponentOutlet="OtherModuleComponent;
ngModuleFactory: myModule;"></ng-container>`
})
export class NgTemplateOutletOtherModuleExample {
// This field is necessary to expose OtherModuleComponent to the template.
OtherModuleComponent = OtherModuleComponent;
myModule: NgModuleFactory<any>;
constructor(compiler: Compiler) { this.myModule = compiler.compileModuleSync(OtherModule); }
}
// #enddocregion
@Component({ @Component({
selector: 'example-app', selector: 'example-app',
template: `<ng-component-outlet-simple-example></ng-component-outlet-simple-example> template: `<ng-component-outlet-simple-example></ng-component-outlet-simple-example>
<hr/> <hr/>
<ng-component-outlet-complete-example></ng-component-outlet-complete-example> <ng-component-outlet-complete-example></ng-component-outlet-complete-example>`
<hr/>
<ng-component-outlet-other-module-example></ng-component-outlet-other-module-example>`
}) })
export class AppComponent { export class AppComponent {
} }
@NgModule({
imports: [CommonModule],
declarations: [OtherModuleComponent],
entryComponents: [OtherModuleComponent]
})
export class OtherModule {
}
export function createCompiler(compilerFactory: CompilerFactory) {
return compilerFactory.createCompiler();
}
@NgModule({ @NgModule({
imports: [BrowserModule], imports: [BrowserModule],
declarations: [ declarations: [
AppComponent, NgTemplateOutletSimpleExample, NgTemplateOutletCompleteExample, AppComponent, NgTemplateOutletSimpleExample, NgTemplateOutletCompleteExample, HelloWorld,
NgTemplateOutletOtherModuleExample, HelloWorld, CompleteComponent CompleteComponent
], ],
entryComponents: [HelloWorld, CompleteComponent], entryComponents: [HelloWorld, CompleteComponent]
providers: [
// Setup the JIT compiler that is not set up by default because the examples
// are bootstrapped using their NgModule factory. Since this example uses the
// JIT compiler, we manually set it up for this module.
{provide: COMPILER_OPTIONS, useValue: {}, multi: true},
{provide: CompilerFactory, useClass: JitCompilerFactory, deps: [COMPILER_OPTIONS]},
{provide: Compiler, useFactory: createCompiler, deps: [CompilerFactory]}
]
}) })
export class AppModule { export class AppModule {
} }