Skip to content
Prev Previous commit
Next Next commit
Add content projection test.
  • Loading branch information
hdeshev committed Mar 8, 2016
commit 3e80602392a42553925ac8973549f9eb14b0dd82
27 changes: 26 additions & 1 deletion tests/app/tests/renderer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class LayoutWithLabel {
})
export class LabelCmp {
constructor(public elementRef: ElementRef){
console.log('LABELCMP');
}
}

Expand All @@ -54,6 +53,24 @@ export class LabelContainer {
constructor(public elementRef: ElementRef){}
}

@Component({
selector: "projectable-cmp",
template: `<StackLayout><ng-content></ng-content></StackLayout>`
})
export class ProjectableCmp {
constructor(public elementRef: ElementRef){
}
}
@Component({
directives: [ProjectableCmp],
template: `<GridLayout>
<projectable-cmp><Button text="projected"></Button></projectable-cmp>
</GridLayout>`
})
export class ProjectionContainer {
constructor(public elementRef: ElementRef){}
}

describe('bootstrap', () => {
let appComponent: App = null;
let _pendingDispose: ComponentRef[] = [];
Expand Down Expand Up @@ -91,6 +108,14 @@ describe('bootstrap', () => {
assert.equal("(ProxyViewContainer (GridLayout (ProxyViewContainer (Label))))", dumpView(componentRoot));
});
});

it("projects content into components", () => {
return loadComponent(ProjectionContainer).then((componentRef) => {
const componentRoot = componentRef.instance.elementRef.nativeElement;
assert.equal("(ProxyViewContainer (GridLayout (ProxyViewContainer (StackLayout (Button)))))", dumpView(componentRoot));
});
});

});

function dumpView(view: View): string {
Expand Down