@@ -29,9 +29,14 @@ describe('Portals', () => {
29
29
30
30
describe ( 'CdkPortalOutlet' , ( ) => {
31
31
let fixture : ComponentFixture < PortalTestApp > ;
32
+ let componentFactoryResolver : ComponentFactoryResolver ;
32
33
33
34
beforeEach ( ( ) => {
34
35
fixture = TestBed . createComponent ( PortalTestApp ) ;
36
+
37
+ inject ( [ ComponentFactoryResolver ] , ( cfr : ComponentFactoryResolver ) => {
38
+ componentFactoryResolver = cfr ;
39
+ } ) ( ) ;
35
40
} ) ;
36
41
37
42
it ( 'should load a component into the portal' , ( ) => {
@@ -311,6 +316,20 @@ describe('Portals', () => {
311
316
expect ( instance . portalOutlet . hasAttached ( ) ) . toBe ( true ) ;
312
317
} ) ;
313
318
319
+ it ( 'should use the `ComponentFactoryResolver` from the portal, if available' , ( ) => {
320
+ const spy = jasmine . createSpy ( 'resolveComponentFactorySpy' ) ;
321
+ const portal = new ComponentPortal ( PizzaMsg , undefined , undefined , {
322
+ resolveComponentFactory : ( ...args : any [ ] ) => {
323
+ spy ( ) ;
324
+ return componentFactoryResolver . resolveComponentFactory
325
+ . apply ( componentFactoryResolver , args ) ;
326
+ }
327
+ } ) ;
328
+
329
+ fixture . componentInstance . portalOutlet . attachComponentPortal ( portal ) ;
330
+ expect ( spy ) . toHaveBeenCalled ( ) ;
331
+ } ) ;
332
+
314
333
} ) ;
315
334
316
335
describe ( 'DomPortalOutlet' , ( ) => {
@@ -324,8 +343,8 @@ describe('Portals', () => {
324
343
let appRef : ApplicationRef ;
325
344
let deps = [ ComponentFactoryResolver , Injector , ApplicationRef ] ;
326
345
327
- beforeEach ( inject ( deps , ( dcl : ComponentFactoryResolver , i : Injector , ar : ApplicationRef ) => {
328
- componentFactoryResolver = dcl ;
346
+ beforeEach ( inject ( deps , ( cfr : ComponentFactoryResolver , i : Injector , ar : ApplicationRef ) => {
347
+ componentFactoryResolver = cfr ;
329
348
injector = i ;
330
349
appRef = ar ;
331
350
} ) ) ;
0 commit comments