test(ivy): view insertion before ng-container with a ViewContainerRef (#33755)

Closes #33679

PR Close #33755
This commit is contained in:
Pawel Kozlowski 2019-11-12 10:29:58 +01:00 committed by Kara Erickson
parent f922903b62
commit 84a0105625
1 changed files with 32 additions and 0 deletions

View File

@ -356,6 +356,7 @@ describe('view insertion', () => {
}); });
it('should insert before a view with an element where ViewContainerRef is injected', () => { it('should insert before a view with an element where ViewContainerRef is injected', () => {
expect(createAndInsertViews(` expect(createAndInsertViews(`
<div [ngTemplateOutlet]="after">|before</div> <div [ngTemplateOutlet]="after">|before</div>
@ -383,6 +384,37 @@ describe('view insertion', () => {
.toBe('insert|before'); .toBe('insert|before');
}); });
it('should insert before a ng-container with a ViewContainerRef on it', () => {
@Component({
selector: 'app-root',
template: `
<div>start|</div>
<ng-container [ngTemplateOutlet]="insertTpl ? tpl : null"></ng-container>
<ng-container [ngTemplateOutlet]="tpl"></ng-container>
<div>|end</div>
<ng-template #tpl>test</ng-template>
`
})
class AppComponent {
insertTpl = false;
}
TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [CommonModule],
});
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.textContent).toBe('start|test|end');
fixture.componentInstance.insertTpl = true;
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.textContent).toBe('start|testtest|end');
});
}); });
describe('before embedded view with projection', () => { describe('before embedded view with projection', () => {