@@ -405,13 +405,15 @@ describe('MatButton', () => {
405
405
describe ( 'interactive disabled buttons' , ( ) => {
406
406
let fixture : ComponentFixture < TestApp > ;
407
407
let button : HTMLButtonElement ;
408
+ let anchor : HTMLAnchorElement ;
408
409
409
410
beforeEach ( ( ) => {
410
411
fixture = TestBed . createComponent ( TestApp ) ;
411
412
fixture . componentInstance . isDisabled = true ;
412
413
fixture . changeDetectorRef . markForCheck ( ) ;
413
414
fixture . detectChanges ( ) ;
414
- button = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
415
+ button = fixture . nativeElement . querySelector ( 'button' ) ;
416
+ anchor = fixture . nativeElement . querySelector ( 'a' ) ;
415
417
} ) ;
416
418
417
419
it ( 'should set a class when allowing disabled interactivity' , ( ) => {
@@ -443,6 +445,29 @@ describe('MatButton', () => {
443
445
444
446
expect ( button . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
445
447
} ) ;
448
+
449
+ it ( 'should set aria-disabled on anchor when disabledInteractive is enabled' , ( ) => {
450
+ fixture . componentInstance . isDisabled = false ;
451
+ fixture . changeDetectorRef . markForCheck ( ) ;
452
+ fixture . detectChanges ( ) ;
453
+ expect ( anchor . hasAttribute ( 'aria-disabled' ) ) . toBe ( false ) ;
454
+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
455
+ expect ( anchor . classList ) . not . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
456
+
457
+ fixture . componentInstance . isDisabled = true ;
458
+ fixture . changeDetectorRef . markForCheck ( ) ;
459
+ fixture . detectChanges ( ) ;
460
+ expect ( anchor . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
461
+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( true ) ;
462
+ expect ( anchor . classList ) . not . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
463
+
464
+ fixture . componentInstance . disabledInteractive = true ;
465
+ fixture . changeDetectorRef . markForCheck ( ) ;
466
+ fixture . detectChanges ( ) ;
467
+ expect ( anchor . getAttribute ( 'aria-disabled' ) ) . toBe ( 'true' ) ;
468
+ expect ( anchor . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
469
+ expect ( anchor . classList ) . toContain ( 'mat-mdc-button-disabled-interactive' ) ;
470
+ } ) ;
446
471
} ) ;
447
472
} ) ;
448
473
0 commit comments