1+ import { Component , ViewChild , ViewContainerRef } from '@angular/core' ;
12import { ComponentFixture , TestBed } from '@angular/core/testing' ;
23import { html } from 'lit-html' ;
34import { AsyncDirective , directive } from 'lit/async-directive.js' ;
@@ -13,22 +14,33 @@ class ToLowerAsyncDirective extends AsyncDirective {
1314 protected override disconnected ( ) : void {
1415 directiveLog . push ( 'disconnected' ) ;
1516 }
16- }
17- export const toLowerAsync = directive ( ToLowerAsyncDirective ) ;
17+ }
18+ export const toLowerAsync = directive ( ToLowerAsyncDirective ) ;
19+
20+ @Component ( {
21+ template : `<igx-template-wrapper></igx-template-wrapper>` ,
22+ imports : [ TemplateWrapperComponent ]
23+ } )
24+ class TestTemplateWrapperComponent {
25+ @ViewChild ( TemplateWrapperComponent )
26+ public templateWrapper ;
27+
28+ constructor ( public viewContainerRef : ViewContainerRef ) { }
29+ }
1830
1931describe ( 'WrapperComponent' , ( ) => {
20- let component : TemplateWrapperComponent ;
21- let fixture : ComponentFixture < TemplateWrapperComponent > ;
32+ let component : TestTemplateWrapperComponent ;
33+ let fixture : ComponentFixture < TestTemplateWrapperComponent > ;
2234
2335 beforeEach ( async ( ) => {
2436 await TestBed . configureTestingModule ( {
25- imports : [ TemplateWrapperComponent ]
37+ imports : [ TestTemplateWrapperComponent ]
2638} )
2739 . compileComponents ( ) ;
2840 } ) ;
2941
3042 beforeEach ( ( ) => {
31- fixture = TestBed . createComponent ( TemplateWrapperComponent ) ;
43+ fixture = TestBed . createComponent ( TestTemplateWrapperComponent ) ;
3244 component = fixture . componentInstance ;
3345 fixture . detectChanges ( ) ;
3446 } ) ;
@@ -39,8 +51,9 @@ describe('WrapperComponent', () => {
3951
4052 it ( 'should render template' , ( ) => {
4153 const context = { text : "Oh hi" } ;
42- const templateRef = component . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ ctx . text } </ span > ` ) ;
54+ const templateRef = component . templateWrapper . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ ctx . text } </ span > ` ) ;
4355 const embeddedView = templateRef . createEmbeddedView ( context ) ;
56+ component . viewContainerRef . insert ( embeddedView ) ;
4457 embeddedView . detectChanges ( ) ;
4558
4659 const span = embeddedView . rootNodes [ 0 ] . querySelector ( "#template1" ) ;
@@ -51,8 +64,9 @@ describe('WrapperComponent', () => {
5164
5265 it ( 'should update connectivity on template with AsyncDirective' , ( ) => {
5366 const context = { text : "OH HI" } ;
54- const templateRef = component . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ toLowerAsync ( ctx . text ) } </ span > ` ) ;
67+ const templateRef = component . templateWrapper . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ toLowerAsync ( ctx . text ) } </ span > ` ) ;
5568 const embeddedView = templateRef . createEmbeddedView ( context ) ;
69+ component . viewContainerRef . insert ( embeddedView ) ;
5670 embeddedView . detectChanges ( ) ;
5771
5872 const span = embeddedView . rootNodes [ 0 ] . querySelector ( "#template1" ) ;
0 commit comments