@@ -271,6 +271,44 @@ export function main() {
271271 } ) ;
272272 } ) ) ;
273273
274+ it ( 'should display even items correctly' ,
275+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
276+ var template =
277+ '<div><copy-me template="ng-for: var item of items; var isEven=even">{{isEven.toString()}}</copy-me></div>' ;
278+
279+ tcb . overrideTemplate ( TestComponent , template )
280+ . createAsync ( TestComponent )
281+ . then ( ( rootTC ) => {
282+ rootTC . debugElement . componentInstance . items = [ 0 , 1 , 2 ] ;
283+ rootTC . detectChanges ( ) ;
284+ expect ( rootTC . debugElement . nativeElement ) . toHaveText ( 'truefalsetrue' ) ;
285+
286+ rootTC . debugElement . componentInstance . items = [ 2 , 1 ] ;
287+ rootTC . detectChanges ( ) ;
288+ expect ( rootTC . debugElement . nativeElement ) . toHaveText ( 'truefalse' ) ;
289+ async . done ( ) ;
290+ } ) ;
291+ } ) ) ;
292+
293+ it ( 'should display odd items correctly' ,
294+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
295+ var template =
296+ '<div><copy-me template="ng-for: var item of items; var isOdd=odd">{{isOdd.toString()}}</copy-me></div>' ;
297+
298+ tcb . overrideTemplate ( TestComponent , template )
299+ . createAsync ( TestComponent )
300+ . then ( ( rootTC ) => {
301+ rootTC . debugElement . componentInstance . items = [ 0 , 1 , 2 , 3 ] ;
302+ rootTC . detectChanges ( ) ;
303+ expect ( rootTC . debugElement . nativeElement ) . toHaveText ( 'falsetruefalsetrue' ) ;
304+
305+ rootTC . debugElement . componentInstance . items = [ 2 , 1 ] ;
306+ rootTC . detectChanges ( ) ;
307+ expect ( rootTC . debugElement . nativeElement ) . toHaveText ( 'falsetrue' ) ;
308+ async . done ( ) ;
309+ } ) ;
310+ } ) ) ;
311+
274312 } ) ;
275313}
276314
0 commit comments