@@ -45,6 +45,26 @@ class MyIfComp {
4545 showMore : boolean = false ;
4646}
4747
48+ @Component ( { selector : 'child-child-comp' } )
49+ @View ( { template : `<span>ChildChild</span>` } )
50+ @Injectable ( )
51+ class ChildChildComp { }
52+
53+ @Component ( { selector : 'child-comp' } )
54+ @View ( { template : `<span>Original {{childBinding}}(<child-child-comp></child-child-comp>)</span>` ,
55+ directives : [ ChildChildComp ] } )
56+ @Injectable ( )
57+ class ChildWithChildComp {
58+ childBinding : string ;
59+ constructor ( ) { this . childBinding = 'Child' ; }
60+ }
61+
62+ @Component ( { selector : 'child-child-comp' } )
63+ @View ( { template : `<span>ChildChild Mock</span>` } )
64+ @Injectable ( )
65+ class MockChildChildComp { }
66+
67+
4868export function main ( ) {
4969 describe ( 'test component builder' , function ( ) {
5070 it ( 'should instantiate a component with valid DOM' ,
@@ -112,5 +132,20 @@ export function main() {
112132 async . done ( ) ;
113133 } ) ;
114134 } ) ) ;
135+
136+
137+ it ( "should override child component's dependencies" ,
138+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb , async ) => {
139+
140+ tcb . overrideDirective ( ParentComp , ChildComp , ChildWithChildComp )
141+ . overrideDirective ( ChildWithChildComp , ChildChildComp , MockChildChildComp )
142+ . createAsync ( ParentComp )
143+ . then ( ( rootTestComponent ) => {
144+ rootTestComponent . detectChanges ( ) ;
145+ expect ( rootTestComponent . nativeElement ) . toHaveText ( 'Parent(Original Child(ChildChild Mock))' ) ;
146+
147+ async . done ( ) ;
148+ } ) ;
149+ } ) ) ;
115150 } ) ;
116151}
0 commit comments