@@ -14,7 +14,7 @@ import {
1414 it ,
1515 xit ,
1616} from 'angular2/testing_internal' ;
17- import { ListWrapper , StringMapWrapper } from 'angular2/src/core/facade/collection' ;
17+ import { ListWrapper , StringMapWrapper , SetWrapper } from 'angular2/src/core/facade/collection' ;
1818import { Component , View , NgFor , provide } from 'angular2/angular2' ;
1919import { NgClass } from 'angular2/src/core/directives/ng_class' ;
2020import { APP_VIEW_POOL_CAPACITY } from 'angular2/src/core/linker/view_pool' ;
@@ -253,6 +253,29 @@ export function main() {
253253 } ) ) ;
254254 } ) ;
255255
256+ describe ( 'expressions evaluating to sets' , ( ) => {
257+
258+ it ( 'should add and remove classes if the set instance changed' ,
259+ inject ( [ TestComponentBuilder , AsyncTestCompleter ] , ( tcb : TestComponentBuilder , async ) => {
260+ var template = '<div [ng-class]="setExpr"></div>' ;
261+
262+ tcb . overrideTemplate ( TestComponent , template )
263+ . createAsync ( TestComponent )
264+ . then ( ( rootTC ) => {
265+ var setExpr = new Set < string > ( ) ;
266+ setExpr . add ( 'bar' ) ;
267+ rootTC . debugElement . componentInstance . setExpr = setExpr ;
268+ detectChangesAndCheck ( rootTC , 'bar' ) ;
269+
270+ setExpr = new Set < string > ( ) ;
271+ setExpr . add ( 'baz' ) ;
272+ rootTC . debugElement . componentInstance . setExpr = setExpr ;
273+ detectChangesAndCheck ( rootTC , 'baz' ) ;
274+
275+ async . done ( ) ;
276+ } ) ;
277+ } ) ) ;
278+ } ) ;
256279 describe ( 'expressions evaluating to string' , ( ) => {
257280
258281 it ( 'should add classes specified in a string literal' ,
@@ -452,6 +475,9 @@ class TestComponent {
452475 condition : boolean = true ;
453476 items : any [ ] ;
454477 arrExpr : string [ ] = [ 'foo' ] ;
478+ setExpr : Set < string > = new Set < string > ( ) ;
455479 objExpr = { 'foo' : true , 'bar' : false } ;
456480 strExpr = 'foo' ;
481+
482+ constructor ( ) { this . setExpr . add ( 'foo' ) ; }
457483}
0 commit comments