@@ -776,6 +776,94 @@ describe('MDC-based MatCheckbox', () => {
776776 } ) ;
777777 } ) ;
778778
779+ describe ( 'with provided aria-expanded' , ( ) => {
780+ let checkboxDebugElement : DebugElement ;
781+ let checkboxNativeElement : HTMLElement ;
782+ let inputElement : HTMLInputElement ;
783+
784+ it ( 'should use the provided postive aria-expanded' , ( ) => {
785+ fixture = createComponent ( CheckboxWithPositiveAriaExpanded ) ;
786+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
787+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
788+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
789+
790+ fixture . detectChanges ( ) ;
791+ expect ( inputElement . getAttribute ( 'aria-expanded' ) ) . toBe ( 'true' ) ;
792+ } ) ;
793+
794+ it ( 'should use the provided negative aria-expanded' , ( ) => {
795+ fixture = createComponent ( CheckboxWithNegativeAriaExpanded ) ;
796+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
797+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
798+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
799+
800+ fixture . detectChanges ( ) ;
801+ expect ( inputElement . getAttribute ( 'aria-expanded' ) ) . toBe ( 'false' ) ;
802+ } ) ;
803+
804+ it ( 'should not assign aria-expanded if none is provided' , ( ) => {
805+ fixture = createComponent ( SingleCheckbox ) ;
806+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
807+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
808+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
809+
810+ fixture . detectChanges ( ) ;
811+ expect ( inputElement . getAttribute ( 'aria-expanded' ) ) . toBe ( null ) ;
812+ } ) ;
813+ } ) ;
814+
815+ describe ( 'with provided aria-controls' , ( ) => {
816+ let checkboxDebugElement : DebugElement ;
817+ let checkboxNativeElement : HTMLElement ;
818+ let inputElement : HTMLInputElement ;
819+
820+ it ( 'should use the provided aria-controls' , ( ) => {
821+ fixture = createComponent ( CheckboxWithAriaControls ) ;
822+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
823+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
824+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
825+
826+ fixture . detectChanges ( ) ;
827+ expect ( inputElement . getAttribute ( 'aria-controls' ) ) . toBe ( 'some-id' ) ;
828+ } ) ;
829+
830+ it ( 'should not assign aria-controls if none is provided' , ( ) => {
831+ fixture = createComponent ( SingleCheckbox ) ;
832+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
833+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
834+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
835+
836+ fixture . detectChanges ( ) ;
837+ expect ( inputElement . getAttribute ( 'aria-controls' ) ) . toBe ( null ) ;
838+ } ) ;
839+ } ) ;
840+
841+ describe ( 'with provided aria-owns' , ( ) => {
842+ let checkboxDebugElement : DebugElement ;
843+ let checkboxNativeElement : HTMLElement ;
844+ let inputElement : HTMLInputElement ;
845+
846+ it ( 'should use the provided aria-owns' , ( ) => {
847+ fixture = createComponent ( CheckboxWithAriaOwns ) ;
848+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
849+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
850+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
851+
852+ fixture . detectChanges ( ) ;
853+ expect ( inputElement . getAttribute ( 'aria-owns' ) ) . toBe ( 'some-id' ) ;
854+ } ) ;
855+
856+ it ( 'should not assign aria-owns if none is provided' , ( ) => {
857+ fixture = createComponent ( SingleCheckbox ) ;
858+ checkboxDebugElement = fixture . debugElement . query ( By . directive ( MatCheckbox ) ) ! ;
859+ checkboxNativeElement = checkboxDebugElement . nativeElement ;
860+ inputElement = < HTMLInputElement > checkboxNativeElement . querySelector ( 'input' ) ;
861+
862+ fixture . detectChanges ( ) ;
863+ expect ( inputElement . getAttribute ( 'aria-owns' ) ) . toBe ( null ) ;
864+ } ) ;
865+ } ) ;
866+
779867 describe ( 'with provided tabIndex' , ( ) => {
780868 let checkboxDebugElement : DebugElement ;
781869 let checkboxNativeElement : HTMLElement ;
@@ -1206,6 +1294,38 @@ class CheckboxWithAriaLabelledby {}
12061294} )
12071295class CheckboxWithAriaDescribedby { }
12081296
1297+ /** Simple test component with an aria-expanded set with true. */
1298+ @Component ( {
1299+ template : `<mat-checkbox aria-expanded="true"></mat-checkbox>` ,
1300+ standalone : true ,
1301+ imports : [ MatCheckbox ] ,
1302+ } )
1303+ class CheckboxWithPositiveAriaExpanded { }
1304+
1305+ /** Simple test component with an aria-expanded set with false. */
1306+ @Component ( {
1307+ template : `<mat-checkbox aria-expanded="false"></mat-checkbox>` ,
1308+ standalone : true ,
1309+ imports : [ MatCheckbox ] ,
1310+ } )
1311+ class CheckboxWithNegativeAriaExpanded { }
1312+
1313+ /** Simple test component with an aria-controls set. */
1314+ @Component ( {
1315+ template : `<mat-checkbox aria-controls="some-id"></mat-checkbox>` ,
1316+ standalone : true ,
1317+ imports : [ MatCheckbox ] ,
1318+ } )
1319+ class CheckboxWithAriaControls { }
1320+
1321+ /** Simple test component with an aria-owns set. */
1322+ @Component ( {
1323+ template : `<mat-checkbox aria-owns="some-id"></mat-checkbox>` ,
1324+ standalone : true ,
1325+ imports : [ MatCheckbox ] ,
1326+ } )
1327+ class CheckboxWithAriaOwns { }
1328+
12091329/** Simple test component with name attribute */
12101330@Component ( {
12111331 template : `<mat-checkbox name="test-name"></mat-checkbox>` ,
0 commit comments