@@ -316,13 +316,15 @@ describe('MatButton', () => {
316316 describe ( 'interactive disabled buttons' , ( ) => {
317317 let fixture : ComponentFixture < TestApp > ;
318318 let button : HTMLButtonElement ;
319+ let anchor : HTMLAnchorElement ;
319320
320321 beforeEach ( ( ) => {
321322 fixture = TestBed . createComponent ( TestApp ) ;
322323 fixture . componentInstance . isDisabled = true ;
323324 fixture . changeDetectorRef . markForCheck ( ) ;
324325 fixture . detectChanges ( ) ;
325- button = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
326+ button = fixture . nativeElement . querySelector ( 'button' ) ;
327+ anchor = fixture . nativeElement . querySelector ( 'a' ) ;
326328 } ) ;
327329
328330 it ( 'should set a class when allowing disabled interactivity' , ( ) => {
@@ -354,6 +356,29 @@ describe('MatButton', () => {
354356
355357 expect ( button . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
356358 } ) ;
359+
360+ it ( 'should set aria-disabled on anchor when disabledInteractive is enabled' , ( ) => {
361+ fixture . componentInstance . isDisabled = false ;
362+ fixture . changeDetectorRef . markForCheck ( ) ;
363+ fixture . detectChanges ( ) ;
364+ expect ( anchor . hasAttribute ( 'aria-disabled' ) ) . toBe ( false ) ;
365+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
366+ expect ( anchor . classList ) . not . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
367+
368+ fixture . componentInstance . isDisabled = true ;
369+ fixture . changeDetectorRef . markForCheck ( ) ;
370+ fixture . detectChanges ( ) ;
371+ expect ( anchor . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
372+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
373+ expect ( anchor . classList ) . not . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
374+
375+ fixture . componentInstance . disabledInteractive = true ;
376+ fixture . changeDetectorRef . markForCheck ( ) ;
377+ fixture . detectChanges ( ) ;
378+ expect ( anchor . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
379+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
380+ expect ( anchor . classList ) . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
381+ } ) ;
357382 } ) ;
358383} ) ;
359384
0 commit comments