@@ -36,6 +36,7 @@ describe('MdCheckbox', () => {
36
36
CheckboxWithNameAttribute ,
37
37
CheckboxWithChangeEvent ,
38
38
CheckboxWithFormControl ,
39
+ CheckboxWithoutLabel ,
39
40
] ,
40
41
providers : [
41
42
{ provide : ViewportRuler , useClass : FakeViewportRuler } ,
@@ -181,7 +182,7 @@ describe('MdCheckbox', () => {
181
182
expect ( rippleElement ) . toBeFalsy ( 'Expected a disabled checkbox not to have a ripple' ) ;
182
183
} ) ;
183
184
184
- it ( 'should not toggle `checked` state upon interation while disabled' , ( ) => {
185
+ it ( 'should not toggle `checked` state upon interaction while disabled' , ( ) => {
185
186
testComponent . isDisabled = true ;
186
187
fixture . detectChanges ( ) ;
187
188
@@ -308,28 +309,28 @@ describe('MdCheckbox', () => {
308
309
it ( 'should apply class based on color attribute' , ( ) => {
309
310
testComponent . checkboxColor = 'primary' ;
310
311
fixture . detectChanges ( ) ;
311
- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
312
+ expect ( checkboxNativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
312
313
313
314
testComponent . checkboxColor = 'accent' ;
314
315
fixture . detectChanges ( ) ;
315
- expect ( checkboxDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
316
+ expect ( checkboxNativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
316
317
} ) ;
317
318
318
319
it ( 'should should not clear previous defined classes' , ( ) => {
319
- checkboxDebugElement . nativeElement . classList . add ( 'custom-class' ) ;
320
+ checkboxNativeElement . classList . add ( 'custom-class' ) ;
320
321
321
322
testComponent . checkboxColor = 'primary' ;
322
323
fixture . detectChanges ( ) ;
323
324
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 ) ;
326
327
327
328
testComponent . checkboxColor = 'accent' ;
328
329
fixture . detectChanges ( ) ;
329
330
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 ) ;
333
334
334
335
} ) ;
335
336
} ) ;
@@ -588,7 +589,6 @@ describe('MdCheckbox', () => {
588
589
} ) ;
589
590
} ) ;
590
591
591
-
592
592
describe ( 'with form control' , ( ) => {
593
593
let checkboxDebugElement : DebugElement ;
594
594
let checkboxInstance : MdCheckbox ;
@@ -617,6 +617,20 @@ describe('MdCheckbox', () => {
617
617
expect ( checkboxInstance . disabled ) . toBe ( false ) ;
618
618
} ) ;
619
619
} ) ;
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
+ } ) ;
620
634
} ) ;
621
635
622
636
/** Simple component for testing a single checkbox. */
@@ -724,3 +738,9 @@ class CheckboxWithChangeEvent {
724
738
class CheckboxWithFormControl {
725
739
formControl = new FormControl ( ) ;
726
740
}
741
+
742
+ /** Test component without label */
743
+ @Component ( {
744
+ template : `<md-checkbox></md-checkbox>`
745
+ } )
746
+ class CheckboxWithoutLabel { }
0 commit comments