@@ -267,6 +267,36 @@ describe('MdCheckbox', () => {
267
267
expect ( inputElement . required ) . toBe ( false ) ;
268
268
} ) ;
269
269
270
+ describe ( 'color behaviour' , ( ) => {
271
+ it ( 'should apply class based on color attribute' , ( ) => {
272
+ testComponent . checkboxColor = 'primary' ;
273
+ fixture . detectChanges ( ) ;
274
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
275
+
276
+ testComponent . checkboxColor = 'accent' ;
277
+ fixture . detectChanges ( ) ;
278
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
279
+ } ) ;
280
+
281
+ it ( 'should should not clear previous defined classes' , ( ) => {
282
+ checkboxDebugElement . nativeElement . classList . add ( 'custom-class' ) ;
283
+
284
+ testComponent . checkboxColor = 'primary' ;
285
+ fixture . detectChanges ( ) ;
286
+
287
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
288
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
289
+
290
+ testComponent . checkboxColor = 'accent' ;
291
+ fixture . detectChanges ( ) ;
292
+
293
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( false ) ;
294
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
295
+ expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
296
+
297
+ } ) ;
298
+ } ) ;
299
+
270
300
describe ( 'state transition css classes' , ( ) => {
271
301
it ( 'should transition unchecked -> checked -> unchecked' , ( ) => {
272
302
testComponent . isChecked = true ;
@@ -519,6 +549,7 @@ describe('MdCheckbox', () => {
519
549
[checked]="isChecked"
520
550
[indeterminate]="isIndeterminate"
521
551
[disabled]="isDisabled"
552
+ [color]="checkboxColor"
522
553
(change)="changeCount = changeCount + 1"
523
554
(click)="onCheckboxClick($event)"
524
555
(change)="onCheckboxChange($event)">
@@ -536,6 +567,7 @@ class SingleCheckbox {
536
567
parentElementKeyedUp : boolean = false ;
537
568
lastKeydownEvent : Event = null ;
538
569
changeCount : number = 0 ;
570
+ checkboxColor : string = 'primary' ;
539
571
540
572
onCheckboxClick ( event : Event ) { }
541
573
onCheckboxChange ( event : MdCheckboxChange ) { }
0 commit comments