1+ import { ChangeDetectorRef , Component , 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,34 @@ 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+ selector : 'igx-test-template-wrapper' ,
22+ templateUrl : './wrapper.component.html' ,
23+ styleUrls : [ './wrapper.component.scss' ] ,
24+ imports : [ ]
25+ } )
26+ class TestTemplateWrapperComponent extends TemplateWrapperComponent {
27+ constructor ( public viewContainerRef : ViewContainerRef , public _cdr : ChangeDetectorRef ) {
28+ super ( _cdr ) ;
29+ }
30+ }
1831
1932describe ( 'WrapperComponent' , ( ) => {
20- let component : TemplateWrapperComponent ;
21- let fixture : ComponentFixture < TemplateWrapperComponent > ;
33+ let component : TestTemplateWrapperComponent ;
34+ let fixture : ComponentFixture < TestTemplateWrapperComponent > ;
2235
2336 beforeEach ( async ( ) => {
2437 await TestBed . configureTestingModule ( {
25- imports : [ TemplateWrapperComponent ]
38+ imports : [ TestTemplateWrapperComponent ]
2639} )
2740 . compileComponents ( ) ;
2841 } ) ;
2942
3043 beforeEach ( ( ) => {
31- fixture = TestBed . createComponent ( TemplateWrapperComponent ) ;
44+ fixture = TestBed . createComponent ( TestTemplateWrapperComponent ) ;
3245 component = fixture . componentInstance ;
3346 fixture . detectChanges ( ) ;
3447 } ) ;
@@ -41,6 +54,7 @@ describe('WrapperComponent', () => {
4154 const context = { text : "Oh hi" } ;
4255 const templateRef = component . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ ctx . text } </ span > ` ) ;
4356 const embeddedView = templateRef . createEmbeddedView ( context ) ;
57+ component . viewContainerRef . insert ( embeddedView ) ;
4458 embeddedView . detectChanges ( ) ;
4559
4660 const span = embeddedView . rootNodes [ 0 ] . querySelector ( "#template1" ) ;
@@ -53,6 +67,7 @@ describe('WrapperComponent', () => {
5367 const context = { text : "OH HI" } ;
5468 const templateRef = component . addTemplate ( ( ctx ) => html `< span id ="template1 "> ${ toLowerAsync ( ctx . text ) } </ span > ` ) ;
5569 const embeddedView = templateRef . createEmbeddedView ( context ) ;
70+ component . viewContainerRef . insert ( embeddedView ) ;
5671 embeddedView . detectChanges ( ) ;
5772
5873 const span = embeddedView . rootNodes [ 0 ] . querySelector ( "#template1" ) ;
0 commit comments