@@ -329,6 +329,39 @@ export function main() {
329329 } ) ;
330330 } ) ) ;
331331
332+ it ( 'should use a default template if a custom one is null' ,
333+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
334+ tcb . overrideTemplate ( TestComponent , `<ul><template ng-for #item [ng-for-of]="items"
335+ [ng-for-template]="contentTpl" #i="index">{{i}}: {{item}};</template></ul>` )
336+ . overrideTemplate ( ComponentUsingTestComponent , '<test-cmp></test-cmp>' )
337+ . createAsync ( ComponentUsingTestComponent )
338+ . then ( ( fixture ) => {
339+ var testComponent = fixture . debugElement . componentViewChildren [ 0 ] ;
340+ testComponent . componentInstance . items = [ 'a' , 'b' , 'c' ] ;
341+ fixture . detectChanges ( ) ;
342+ expect ( testComponent . nativeElement ) . toHaveText ( '0: a;1: b;2: c;' ) ;
343+
344+ async . done ( ) ;
345+ } ) ;
346+ } ) ) ;
347+
348+ it ( 'should use a custom template when both default and a custom one are present' ,
349+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
350+ tcb . overrideTemplate ( TestComponent , `<ul><template ng-for #item [ng-for-of]="items"
351+ [ng-for-template]="contentTpl" #i="index">{{i}}=> {{item}};</template></ul>` )
352+ . overrideTemplate (
353+ ComponentUsingTestComponent ,
354+ '<test-cmp><li template="#item #i=index">{{i}}: {{item}};</li></test-cmp>' )
355+ . createAsync ( ComponentUsingTestComponent )
356+ . then ( ( fixture ) => {
357+ var testComponent = fixture . debugElement . componentViewChildren [ 0 ] ;
358+ testComponent . componentInstance . items = [ 'a' , 'b' , 'c' ] ;
359+ fixture . detectChanges ( ) ;
360+ expect ( testComponent . nativeElement ) . toHaveText ( '0: a;1: b;2: c;' ) ;
361+
362+ async . done ( ) ;
363+ } ) ;
364+ } ) ) ;
332365 } ) ;
333366}
334367
0 commit comments