test(ivy): non-regression test for ViewContainerRef queried on ng-container (#33939)
Closes #31971 PR Close #33939
This commit is contained in:
parent
27562e92db
commit
51cee50ee3
|
@ -543,8 +543,58 @@ describe('view insertion', () => {
|
|||
|
||||
describe('non-regression', () => {
|
||||
|
||||
// https://github.com/angular/angular/issues/31971
|
||||
it('should insert component views into ViewContainerRef injected by querying <ng-container>',
|
||||
() => {
|
||||
|
||||
@Component({selector: 'dynamic-cmpt', template: 'dynamic'})
|
||||
class DynamicComponent {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<div>start|</div>
|
||||
<ng-container #container></ng-container>
|
||||
<div>|end</div>
|
||||
|
||||
<div (click)="click()" >|click</div>
|
||||
`
|
||||
})
|
||||
class AppComponent {
|
||||
@ViewChild('container', {read: ViewContainerRef, static: true})
|
||||
vcr !: ViewContainerRef;
|
||||
|
||||
constructor(private _cfr: ComponentFactoryResolver) {}
|
||||
|
||||
click() {
|
||||
this.vcr.createComponent(this._cfr.resolveComponentFactory(DynamicComponent));
|
||||
}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [DynamicComponent],
|
||||
entryComponents: [DynamicComponent],
|
||||
})
|
||||
class TestModule {
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppComponent],
|
||||
imports: [TestModule],
|
||||
});
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toBe('start||end|click');
|
||||
|
||||
fixture.componentInstance.click();
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toBe('start|dynamic|end|click');
|
||||
});
|
||||
|
||||
// https://github.com/angular/angular/issues/33679
|
||||
it('should insert views into ViewContainerRef injected by querying <ng-container>', () => {
|
||||
it('should insert embedded views into ViewContainerRef injected by querying <ng-container>',
|
||||
() => {
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
|
|
Loading…
Reference in New Issue