@@ -32,6 +32,7 @@ describe('MdCheckbox', () => {
3232 CheckboxWithNameAttribute ,
3333 CheckboxWithChangeEvent ,
3434 CheckboxWithFormControl ,
35+ CheckboxWithoutLabel ,
3536 ] ,
3637 providers : [
3738 { provide : ViewportRuler , useClass : FakeViewportRuler }
@@ -436,28 +437,28 @@ describe('MdCheckbox', () => {
436437 it ( 'should apply class based on color attribute' , ( ) => {
437438 testComponent . checkboxColor = 'primary' ;
438439 fixture . detectChanges ( ) ;
439- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( true ) ;
440+ expect ( checkboxNativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( true ) ;
440441
441442 testComponent . checkboxColor = 'accent' ;
442443 fixture . detectChanges ( ) ;
443- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'mat-accent' ) ) . toBe ( true ) ;
444+ expect ( checkboxNativeElement . classList . contains ( 'mat-accent' ) ) . toBe ( true ) ;
444445 } ) ;
445446
446447 it ( 'should should not clear previous defined classes' , ( ) => {
447- checkboxDebugElement . nativeElement . classList . add ( 'custom-class' ) ;
448+ checkboxNativeElement . classList . add ( 'custom-class' ) ;
448449
449450 testComponent . checkboxColor = 'primary' ;
450451 fixture . detectChanges ( ) ;
451452
452- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( true ) ;
453- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
453+ expect ( checkboxNativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( true ) ;
454+ expect ( checkboxNativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
454455
455456 testComponent . checkboxColor = 'accent' ;
456457 fixture . detectChanges ( ) ;
457458
458- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( false ) ;
459- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'mat-accent' ) ) . toBe ( true ) ;
460- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
459+ expect ( checkboxNativeElement . classList . contains ( 'mat-primary' ) ) . toBe ( false ) ;
460+ expect ( checkboxNativeElement . classList . contains ( 'mat-accent' ) ) . toBe ( true ) ;
461+ expect ( checkboxNativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
461462
462463 } ) ;
463464 } ) ;
@@ -730,7 +731,6 @@ describe('MdCheckbox', () => {
730731 } ) ;
731732 } ) ;
732733
733-
734734 describe ( 'with form control' , ( ) => {
735735 let checkboxDebugElement : DebugElement ;
736736 let checkboxInstance : MdCheckbox ;
@@ -763,6 +763,22 @@ describe('MdCheckbox', () => {
763763 expect ( inputElement . disabled ) . toBe ( false ) ;
764764 } ) ;
765765 } ) ;
766+
767+ describe ( 'without label' , ( ) => {
768+ let checkboxDebugElement : DebugElement ;
769+ let checkboxNativeElement : HTMLElement ;
770+
771+ it ( 'should add a css class to inner-container to remove side margin' , ( ) => {
772+ fixture = TestBed . createComponent ( CheckboxWithoutLabel ) ;
773+ fixture . detectChanges ( ) ;
774+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MdCheckbox ) ) ;
775+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
776+
777+ let checkboxInnerContainerWithoutMarginCount = checkboxNativeElement
778+ . querySelectorAll ( '.mat-checkbox-inner-container-no-side-margin' ) . length ;
779+ expect ( checkboxInnerContainerWithoutMarginCount ) . toBe ( 1 ) ;
780+ } ) ;
781+ } ) ;
766782} ) ;
767783
768784/** Simple component for testing a single checkbox. */
@@ -872,3 +888,9 @@ class CheckboxWithChangeEvent {
872888class CheckboxWithFormControl {
873889 formControl = new FormControl ( ) ;
874890}
891+
892+ /** Test component without label */
893+ @Component ( {
894+ template : `<md-checkbox></md-checkbox>`
895+ } )
896+ class CheckboxWithoutLabel { }
0 commit comments