@@ -14,13 +14,36 @@ import {
1414 xit ,
1515} from 'angular2/test_lib' ;
1616import { List , ListWrapper , StringMapWrapper } from 'angular2/src/facade/collection' ;
17- import { Component , View } from 'angular2/angular2' ;
17+ import { Component , View , NgFor , bind } from 'angular2/angular2' ;
1818import { DOM } from 'angular2/src/dom/dom_adapter' ;
1919import { CSSClass } from 'angular2/src/directives/class' ;
20+ import { APP_VIEW_POOL_CAPACITY } from 'angular2/src/core/compiler/view_pool' ;
2021
2122export function main ( ) {
2223 describe ( 'binding to CSS class list' , ( ) => {
2324
25+ describe ( 'viewpool support' , ( ) => {
26+ beforeEachBindings ( ( ) => { return [ bind ( APP_VIEW_POOL_CAPACITY ) . toValue ( 100 ) ] ; } ) ;
27+
28+ it ( 'should clean up when the directive is destroyed' ,
29+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
30+ var template = '<div *ng-for="var item of items" [class]="item"></div>' ;
31+ tcb . overrideTemplate ( TestComponent , template )
32+ . createAsync ( TestComponent )
33+ . then ( ( rootTC ) => {
34+ rootTC . componentInstance . items = [ [ '0' ] ] ;
35+ rootTC . detectChanges ( ) ;
36+ rootTC . componentInstance . items = [ [ '1' ] ] ;
37+ rootTC . detectChanges ( ) ;
38+ expect ( rootTC . componentViewChildren [ 1 ] . nativeElement . className )
39+ . toEqual ( 'ng-binding 1' ) ;
40+
41+ async . done ( ) ;
42+ } ) ;
43+ } ) ) ;
44+ } ) ;
45+
46+
2447 describe ( 'expressions evaluating to objects' , ( ) => {
2548
2649 it ( 'should add classes specified in an object literal' ,
@@ -344,9 +367,10 @@ export function main() {
344367}
345368
346369@Component ( { selector : 'test-cmp' } )
347- @View ( { directives : [ CSSClass ] } )
370+ @View ( { directives : [ CSSClass , NgFor ] } )
348371class TestComponent {
349372 condition : boolean = true ;
373+ items : any [ ] ;
350374 arrExpr : List < string > = [ 'foo' ] ;
351375 objExpr = { 'foo' : true , 'bar' : false } ;
352376 strExpr = 'foo' ;
0 commit comments