@@ -316,13 +316,15 @@ describe('MatButton', () => {
316
316
describe ( 'interactive disabled buttons' , ( ) => {
317
317
let fixture : ComponentFixture < TestApp > ;
318
318
let button : HTMLButtonElement ;
319
+ let anchor : HTMLAnchorElement ;
319
320
320
321
beforeEach ( ( ) => {
321
322
fixture = TestBed . createComponent ( TestApp ) ;
322
323
fixture . componentInstance . isDisabled = true ;
323
324
fixture . changeDetectorRef . markForCheck ( ) ;
324
325
fixture . detectChanges ( ) ;
325
- button = fixture . debugElement . query ( By . css ( 'button' ) ) ! . nativeElement ;
326
+ button = fixture . nativeElement . querySelector ( 'button' ) ;
327
+ anchor = fixture . nativeElement . querySelector ( 'a' ) ;
326
328
} ) ;
327
329
328
330
it ( 'should set a class when allowing disabled interactivity' , ( ) => {
@@ -354,6 +356,29 @@ describe('MatButton', () => {
354
356
355
357
expect ( button . hasAttribute ( 'disabled' ) ) . toBe ( false ) ;
356
358
} ) ;
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
+ } ) ;
357
382
} ) ;
358
383
} ) ;
359
384
0 commit comments