6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { APP_BOOTSTRAP_LISTENER , APP_INITIALIZER , Compiler , CompilerFactory , Component , NgModule , NgZone , PlatformRef , TemplateRef , Type , ViewChild , ViewContainerRef } from '@angular/core' ;
9
+ import { APP_BOOTSTRAP_LISTENER , APP_INITIALIZER , Compiler , CompilerFactory , Component , InjectionToken , NgModule , NgZone , PlatformRef , TemplateRef , Type , ViewChild , ViewContainerRef } from '@angular/core' ;
10
10
import { ApplicationRef } from '@angular/core/src/application_ref' ;
11
11
import { ErrorHandler } from '@angular/core/src/error_handler' ;
12
12
import { ComponentRef } from '@angular/core/src/linker/component_factory' ;
@@ -15,7 +15,7 @@ import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
15
15
import { DOCUMENT } from '@angular/platform-browser/src/dom/dom_tokens' ;
16
16
import { dispatchEvent } from '@angular/platform-browser/testing/src/browser_util' ;
17
17
import { expect } from '@angular/platform-browser/testing/src/matchers' ;
18
- import { fixmeIvy , ivyEnabled , modifiedInIvy } from '@angular/private/testing' ;
18
+ import { ivyEnabled } from '@angular/private/testing' ;
19
19
20
20
import { NoopNgZone } from '../src/zone/ng_zone' ;
21
21
import { ComponentFixtureNoNgZone , TestBed , async , inject , withModule } from '../testing' ;
@@ -74,63 +74,65 @@ class SomeComponent {
74
74
return MyModule ;
75
75
}
76
76
77
- fixmeIvy ( 'FW-776: Cannot bootstrap as there are still asynchronous initializers running' )
78
- . it ( 'should bootstrap a component from a child module' ,
79
- async ( inject ( [ ApplicationRef , Compiler ] , ( app : ApplicationRef , compiler : Compiler ) => {
80
- @Component ( {
81
- selector : 'bootstrap-app' ,
82
- template : '' ,
83
- } )
84
- class SomeComponent {
85
- }
86
-
87
- @NgModule ( {
88
- providers : [ { provide : 'hello' , useValue : 'component' } ] ,
89
- declarations : [ SomeComponent ] ,
90
- entryComponents : [ SomeComponent ] ,
91
- } )
92
- class SomeModule {
93
- }
94
-
95
- createRootEl ( ) ;
96
- const modFactory = compiler . compileModuleSync ( SomeModule ) ;
97
- const module = modFactory . create ( TestBed ) ;
98
- const cmpFactory =
99
- module . componentFactoryResolver . resolveComponentFactory ( SomeComponent ) ! ;
100
- const component = app . bootstrap ( cmpFactory ) ;
101
-
102
- // The component should see the child module providers
103
- expect ( component . injector . get ( 'hello' ) ) . toEqual ( 'component' ) ;
104
- } ) ) ) ;
105
-
106
- fixmeIvy ( 'FW-776: Cannot bootstrap as there are still asynchronous initializers running' )
107
- . it ( 'should bootstrap a component with a custom selector' ,
108
- async ( inject ( [ ApplicationRef , Compiler ] , ( app : ApplicationRef , compiler : Compiler ) => {
109
- @Component ( {
110
- selector : 'bootstrap-app' ,
111
- template : '' ,
112
- } )
113
- class SomeComponent {
114
- }
115
-
116
- @NgModule ( {
117
- providers : [ { provide : 'hello' , useValue : 'component' } ] ,
118
- declarations : [ SomeComponent ] ,
119
- entryComponents : [ SomeComponent ] ,
120
- } )
121
- class SomeModule {
122
- }
123
-
124
- createRootEl ( 'custom-selector' ) ;
125
- const modFactory = compiler . compileModuleSync ( SomeModule ) ;
126
- const module = modFactory . create ( TestBed ) ;
127
- const cmpFactory =
128
- module . componentFactoryResolver . resolveComponentFactory ( SomeComponent ) ! ;
129
- const component = app . bootstrap ( cmpFactory , 'custom-selector' ) ;
130
-
131
- // The component should see the child module providers
132
- expect ( component . injector . get ( 'hello' ) ) . toEqual ( 'component' ) ;
133
- } ) ) ) ;
77
+ it ( 'should bootstrap a component from a child module' ,
78
+ async ( inject ( [ ApplicationRef , Compiler ] , ( app : ApplicationRef , compiler : Compiler ) => {
79
+ @Component ( {
80
+ selector : 'bootstrap-app' ,
81
+ template : '' ,
82
+ } )
83
+ class SomeComponent {
84
+ }
85
+
86
+ const helloToken = new InjectionToken < string > ( 'hello' ) ;
87
+
88
+ @NgModule ( {
89
+ providers : [ { provide : helloToken , useValue : 'component' } ] ,
90
+ declarations : [ SomeComponent ] ,
91
+ entryComponents : [ SomeComponent ] ,
92
+ } )
93
+ class SomeModule {
94
+ }
95
+
96
+ createRootEl ( ) ;
97
+ const modFactory = compiler . compileModuleSync ( SomeModule ) ;
98
+ const module = modFactory . create ( TestBed ) ;
99
+ const cmpFactory =
100
+ module . componentFactoryResolver . resolveComponentFactory ( SomeComponent ) ! ;
101
+ const component = app . bootstrap ( cmpFactory ) ;
102
+
103
+ // The component should see the child module providers
104
+ expect ( component . injector . get ( helloToken ) ) . toEqual ( 'component' ) ;
105
+ } ) ) ) ;
106
+
107
+ it ( 'should bootstrap a component with a custom selector' ,
108
+ async ( inject ( [ ApplicationRef , Compiler ] , ( app : ApplicationRef , compiler : Compiler ) => {
109
+ @Component ( {
110
+ selector : 'bootstrap-app' ,
111
+ template : '' ,
112
+ } )
113
+ class SomeComponent {
114
+ }
115
+
116
+ const helloToken = new InjectionToken < string > ( 'hello' ) ;
117
+
118
+ @NgModule ( {
119
+ providers : [ { provide : helloToken , useValue : 'component' } ] ,
120
+ declarations : [ SomeComponent ] ,
121
+ entryComponents : [ SomeComponent ] ,
122
+ } )
123
+ class SomeModule {
124
+ }
125
+
126
+ createRootEl ( 'custom-selector' ) ;
127
+ const modFactory = compiler . compileModuleSync ( SomeModule ) ;
128
+ const module = modFactory . create ( TestBed ) ;
129
+ const cmpFactory =
130
+ module . componentFactoryResolver . resolveComponentFactory ( SomeComponent ) ! ;
131
+ const component = app . bootstrap ( cmpFactory , 'custom-selector' ) ;
132
+
133
+ // The component should see the child module providers
134
+ expect ( component . injector . get ( helloToken ) ) . toEqual ( 'component' ) ;
135
+ } ) ) ) ;
134
136
135
137
describe ( 'ApplicationRef' , ( ) => {
136
138
beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ createModule ( ) ] } ) ; } ) ;
0 commit comments