@@ -702,6 +702,32 @@ describe('MDC-based MatCheckbox', () => {
702702 } ) ) ;
703703 } ) ;
704704
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+
705731 describe ( 'with provided tabIndex' , ( ) => {
706732 let checkboxDebugElement : DebugElement ;
707733 let checkboxNativeElement : HTMLElement ;
@@ -1111,6 +1137,12 @@ class CheckboxWithAriaLabel {
11111137class CheckboxWithAriaLabelledby {
11121138}
11131139
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+
11141146/** Simple test component with name attribute */
11151147@Component ( { template : `<mat-checkbox name="test-name"></mat-checkbox>` } )
11161148class CheckboxWithNameAttribute {
0 commit comments