@@ -702,6 +702,32 @@ describe('MDC-based MatCheckbox', () => {
702
702
} ) ) ;
703
703
} ) ;
704
704
705
+ describe ( 'with provided aria-describedby ' , ( ) => {
706
+ let checkboxDebugElement : DebugElement ;
707
+ let checkboxNativeElement : HTMLElement ;
708
+ let inputElement : HTMLInputElement ;
709
+
710
+ it ( 'should use the provided aria-describedby' , ( ) => {
711
+ fixture = createComponent ( CheckboxWithAriaDescribedby ) ;
712
+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
713
+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
714
+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
715
+
716
+ fixture . detectChanges ( ) ;
717
+ expect ( inputElement . getAttribute ( 'aria-describedby' ) ) . toBe ( 'some-id' ) ;
718
+ } ) ;
719
+
720
+ it ( 'should not assign aria-describedby if none is provided' , ( ) => {
721
+ fixture = createComponent ( SingleCheckbox ) ;
722
+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
723
+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
724
+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
725
+
726
+ fixture . detectChanges ( ) ;
727
+ expect ( inputElement . getAttribute ( 'aria-describedby' ) ) . toBe ( null ) ;
728
+ } ) ;
729
+ } ) ;
730
+
705
731
describe ( 'with provided tabIndex' , ( ) => {
706
732
let checkboxDebugElement : DebugElement ;
707
733
let checkboxNativeElement : HTMLElement ;
@@ -1111,6 +1137,12 @@ class CheckboxWithAriaLabel {
1111
1137
class CheckboxWithAriaLabelledby {
1112
1138
}
1113
1139
1140
+ /** Simple test component with an aria-describedby set. */
1141
+ @Component ( {
1142
+ template : `<mat-checkbox aria-describedby="some-id"></mat-checkbox>`
1143
+ } )
1144
+ class CheckboxWithAriaDescribedby { }
1145
+
1114
1146
/** Simple test component with name attribute */
1115
1147
@Component ( { template : `<mat-checkbox name="test-name"></mat-checkbox>` } )
1116
1148
class CheckboxWithNameAttribute {
0 commit comments