diff --git a/modules/angular2/src/mock/directive_resolver_mock.ts b/modules/angular2/src/mock/directive_resolver_mock.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/modules/angular2/test/test_lib/test_component_builder_spec.ts b/modules/angular2/test/test_lib/test_component_builder_spec.ts index 8ba7c38651..911f140be8 100644 --- a/modules/angular2/test/test_lib/test_component_builder_spec.ts +++ b/modules/angular2/test/test_lib/test_component_builder_spec.ts @@ -45,6 +45,26 @@ class MyIfComp { showMore: boolean = false; } +@Component({selector: 'child-child-comp'}) +@View({template: `ChildChild`}) +@Injectable() +class ChildChildComp {} + +@Component({selector: 'child-comp'}) +@View({template: `Original {{childBinding}}()`, + directives: [ChildChildComp]}) +@Injectable() +class ChildWithChildComp { + childBinding: string; + constructor() { this.childBinding = 'Child'; } +} + +@Component({selector: 'child-child-comp'}) +@View({template: `ChildChild Mock`}) +@Injectable() +class MockChildChildComp {} + + export function main() { describe('test component builder', function() { it('should instantiate a component with valid DOM', @@ -112,5 +132,20 @@ export function main() { async.done(); }); })); + + + it("should override child component's dependencies", + inject([TestComponentBuilder, AsyncTestCompleter], (tcb, async) => { + + tcb.overrideDirective(ParentComp, ChildComp, ChildWithChildComp) + .overrideDirective(ChildWithChildComp, ChildChildComp, MockChildChildComp) + .createAsync(ParentComp) + .then((rootTestComponent) => { + rootTestComponent.detectChanges(); + expect(rootTestComponent.nativeElement).toHaveText('Parent(Original Child(ChildChild Mock))'); + + async.done(); + }); + })); }); }