@@ -36,6 +36,7 @@ describe('MdCheckbox', () => {
3636 CheckboxWithNameAttribute ,
3737 CheckboxWithChangeEvent ,
3838 CheckboxWithFormControl ,
39+ CheckboxWithoutLabel ,
3940 ] ,
4041 providers : [
4142 { provide : ViewportRuler , useClass : FakeViewportRuler } ,
@@ -181,7 +182,7 @@ describe('MdCheckbox', () => {
181182 expect ( rippleElement ) . toBeFalsy ( 'Expected a disabled checkbox not to have a ripple' ) ;
182183 } ) ;
183184
184- it ( 'should not toggle `checked` state upon interation while disabled' , ( ) => {
185+ it ( 'should not toggle `checked` state upon interaction while disabled' , ( ) => {
185186 testComponent . isDisabled = true ;
186187 fixture . detectChanges ( ) ;
187188
@@ -308,28 +309,28 @@ describe('MdCheckbox', () => {
308309 it ( 'should apply class based on color attribute' , ( ) => {
309310 testComponent . checkboxColor = 'primary' ;
310311 fixture . detectChanges ( ) ;
311- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
312+ expect ( checkboxNativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
312313
313314 testComponent . checkboxColor = 'accent' ;
314315 fixture . detectChanges ( ) ;
315- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
316+ expect ( checkboxNativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
316317 } ) ;
317318
318319 it ( 'should should not clear previous defined classes' , ( ) => {
319- checkboxDebugElement . nativeElement . classList . add ( 'custom-class' ) ;
320+ checkboxNativeElement . classList . add ( 'custom-class' ) ;
320321
321322 testComponent . checkboxColor = 'primary' ;
322323 fixture . detectChanges ( ) ;
323324
324- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
325- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
325+ expect ( checkboxNativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
326+ expect ( checkboxNativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
326327
327328 testComponent . checkboxColor = 'accent' ;
328329 fixture . detectChanges ( ) ;
329330
330- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( false ) ;
331- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
332- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
331+ expect ( checkboxNativeElement . classList . contains ( 'md-primary' ) ) . toBe ( false ) ;
332+ expect ( checkboxNativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
333+ expect ( checkboxNativeElement . classList . contains ( 'custom-class' ) ) . toBe ( true ) ;
333334
334335 } ) ;
335336 } ) ;
@@ -588,7 +589,6 @@ describe('MdCheckbox', () => {
588589 } ) ;
589590 } ) ;
590591
591-
592592 describe ( 'with form control' , ( ) => {
593593 let checkboxDebugElement : DebugElement ;
594594 let checkboxInstance : MdCheckbox ;
@@ -617,6 +617,20 @@ describe('MdCheckbox', () => {
617617 expect ( checkboxInstance . disabled ) . toBe ( false ) ;
618618 } ) ;
619619 } ) ;
620+
621+ describe ( 'without label' , ( ) => {
622+ let checkboxDebugElement : DebugElement ;
623+ let checkboxNativeElement : HTMLElement ;
624+
625+ it ( 'should add a css class to inner-container to remove side margin' , ( ) => {
626+ fixture = TestBed . createComponent ( CheckboxWithoutLabel ) ;
627+ fixture . detectChanges ( ) ;
628+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MdCheckbox ) ) ;
629+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
630+
631+ expect ( checkboxNativeElement . querySelectorAll ( '.md-checkbox-inner-container-no-side-margin' ) . length ) . toBe ( 1 ) ;
632+ } ) ;
633+ } ) ;
620634} ) ;
621635
622636/** Simple component for testing a single checkbox. */
@@ -724,3 +738,9 @@ class CheckboxWithChangeEvent {
724738class CheckboxWithFormControl {
725739 formControl = new FormControl ( ) ;
726740}
741+
742+ /** Test component without label */
743+ @Component ( {
744+ template : `<md-checkbox></md-checkbox>`
745+ } )
746+ class CheckboxWithoutLabel { }
0 commit comments