fix: broken build due to bad noImplicitAny merge

This commit is contained in:
Misko Hevery 2016-06-10 10:35:36 -07:00
parent 164a091c71
commit 9c0031f7a5
1 changed files with 76 additions and 62 deletions

View File

@ -96,90 +96,104 @@ export function main() {
})); }));
it('should display template if context is null', it('should display template if context is null',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject(
var template = `<tpl-refs #refs="tplRefs"><template>foo</template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="null"></template>`; [TestComponentBuilder, AsyncTestCompleter],
tcb.overrideTemplate(TestComponent, template) (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
.createAsync(TestComponent) var template =
.then((fixture) => { `<tpl-refs #refs="tplRefs"><template>foo</template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="null"></template>`;
tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.nativeElement).toHaveText(''); expect(fixture.nativeElement).toHaveText('');
var refs = fixture.debugElement.children[0].references['refs']; var refs = fixture.debugElement.children[0].references['refs'];
fixture.componentInstance.currentTplRef = refs.tplRefs.first; fixture.componentInstance.currentTplRef = refs.tplRefs.first;
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.nativeElement).toHaveText('foo'); expect(fixture.nativeElement).toHaveText('foo');
async.done(); async.done();
}); });
})); }));
it('should reflect initial context and changes', it('should reflect initial context and changes',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject(
var template =`<tpl-refs #refs="tplRefs"><template let-foo="foo"><span>{{foo}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`; [TestComponentBuilder, AsyncTestCompleter],
tcb.overrideTemplate(TestComponent, template) (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
.createAsync(TestComponent) var template =
.then((fixture) => { `<tpl-refs #refs="tplRefs"><template let-foo="foo"><span>{{foo}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`;
fixture.detectChanges(); tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
var refs = fixture.debugElement.children[0].references['refs']; var refs = fixture.debugElement.children[0].references['refs'];
fixture.componentInstance.currentTplRef = refs.tplRefs.first; fixture.componentInstance.currentTplRef = refs.tplRefs.first;
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('bar'); expect(fixture.debugElement.nativeElement).toHaveText('bar');
fixture.componentInstance.context.foo = 'alter-bar'; fixture.componentInstance.context.foo = 'alter-bar';
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('alter-bar'); expect(fixture.debugElement.nativeElement).toHaveText('alter-bar');
async.done(); async.done();
}); });
})); }));
it('should reflect user defined $implicit property in the context', it('should reflect user defined $implicit property in the context',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject(
var template =`<tpl-refs #refs="tplRefs"><template let-ctx><span>{{ctx.foo}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`; [TestComponentBuilder, AsyncTestCompleter],
tcb.overrideTemplate(TestComponent, template) (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
.createAsync(TestComponent) var template =
.then((fixture) => { `<tpl-refs #refs="tplRefs"><template let-ctx><span>{{ctx.foo}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`;
fixture.detectChanges(); tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
var refs = fixture.debugElement.children[0].references['refs']; var refs = fixture.debugElement.children[0].references['refs'];
fixture.componentInstance.currentTplRef = refs.tplRefs.first; fixture.componentInstance.currentTplRef = refs.tplRefs.first;
fixture.componentInstance.context = { $implicit: fixture.componentInstance.context }; fixture.componentInstance.context = {
fixture.detectChanges(); $implicit: fixture.componentInstance.context
expect(fixture.debugElement.nativeElement).toHaveText('bar'); };
fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('bar');
async.done(); async.done();
}); });
})); }));
it('should reflect context re-binding', it('should reflect context re-binding',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => { inject(
var template =`<tpl-refs #refs="tplRefs"><template let-shawshank="shawshank"><span>{{shawshank}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`; [TestComponentBuilder, AsyncTestCompleter],
tcb.overrideTemplate(TestComponent, template) (tcb: TestComponentBuilder, async: AsyncTestCompleter) => {
.createAsync(TestComponent) var template =
.then((fixture) => { `<tpl-refs #refs="tplRefs"><template let-shawshank="shawshank"><span>{{shawshank}}</span></template></tpl-refs><template [ngTemplateOutlet]="currentTplRef" [ngOutletContext]="context"></template>`;
fixture.detectChanges(); tcb.overrideTemplate(TestComponent, template)
.createAsync(TestComponent)
.then((fixture) => {
fixture.detectChanges();
var refs = fixture.debugElement.children[0].references['refs']; var refs = fixture.debugElement.children[0].references['refs'];
fixture.componentInstance.currentTplRef = refs.tplRefs.first; fixture.componentInstance.currentTplRef = refs.tplRefs.first;
fixture.componentInstance.context = { shawshank: 'brooks' }; fixture.componentInstance.context = {shawshank: 'brooks'};
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('brooks'); expect(fixture.debugElement.nativeElement).toHaveText('brooks');
fixture.componentInstance.context = { shawshank: 'was here' }; fixture.componentInstance.context = {shawshank: 'was here'};
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement).toHaveText('was here'); expect(fixture.debugElement.nativeElement).toHaveText('was here');
async.done(); async.done();
}); });
})); }));
}); });
} }
@ -192,5 +206,5 @@ class CaptureTplRefs {
@Component({selector: 'test-cmp', directives: [NgTemplateOutlet, CaptureTplRefs], template: ''}) @Component({selector: 'test-cmp', directives: [NgTemplateOutlet, CaptureTplRefs], template: ''})
class TestComponent { class TestComponent {
currentTplRef: TemplateRef<any>; currentTplRef: TemplateRef<any>;
context: any = { foo: 'bar' }; context: any = {foo: 'bar'};
} }