@@ -311,41 +311,48 @@ describe('MdDialog', () => {
311311 } ) ;
312312
313313 describe ( 'dialog content elements' , ( ) => {
314- let fixture : ComponentFixture < ContentElementDialog > ;
315- let dialogElement : HTMLElement ;
314+ let dialogRef : MdDialogRef < ContentElementDialog > ;
316315
317316 beforeEach ( ( ) => {
318- fixture = TestBed . createComponent ( ContentElementDialog ) ;
319- dialogElement = fixture . debugElement . nativeElement ;
320- dialog . open ( ContentElementDialog ) ;
321- fixture . detectChanges ( ) ;
317+ dialogRef = dialog . open ( ContentElementDialog ) ;
318+ viewContainerFixture . detectChanges ( ) ;
322319 } ) ;
323320
324- it ( 'close the dialog when clicking on the close button' , ( ) => {
321+ it ( 'should close the dialog when clicking on the close button' , ( ) => {
325322 expect ( overlayContainerElement . querySelectorAll ( '.md-dialog-container' ) . length ) . toBe ( 1 ) ;
326323
327- ( dialogElement . querySelector ( 'button[md-dialog-close]' ) as HTMLElement ) . click ( ) ;
324+ ( overlayContainerElement . querySelector ( 'button[md-dialog-close]' ) as HTMLElement ) . click ( ) ;
328325
329326 expect ( overlayContainerElement . querySelectorAll ( '.md-dialog-container' ) . length ) . toBe ( 0 ) ;
330327 } ) ;
331328
332- it ( 'close not close the dialog if [md-dialog-close] is applied on a non-button node' , ( ) => {
329+ it ( 'should not close the dialog if [md-dialog-close] is applied on a non-button node' , ( ) => {
333330 expect ( overlayContainerElement . querySelectorAll ( '.md-dialog-container' ) . length ) . toBe ( 1 ) ;
334331
335- ( dialogElement . querySelector ( 'div[md-dialog-close]' ) as HTMLElement ) . click ( ) ;
332+ ( overlayContainerElement . querySelector ( 'div[md-dialog-close]' ) as HTMLElement ) . click ( ) ;
336333
337334 expect ( overlayContainerElement . querySelectorAll ( '.md-dialog-container' ) . length ) . toBe ( 1 ) ;
338335 } ) ;
339336
337+ it ( 'should allow for a user-specified aria-label on the close button' , ( ) => {
338+ let button = overlayContainerElement . querySelector ( 'button[md-dialog-close]' ) ;
339+
340+ dialogRef . componentInstance . closeButtonAriaLabel = 'Best close button ever' ;
341+ viewContainerFixture . detectChanges ( ) ;
342+
343+ expect ( button . getAttribute ( 'aria-label' ) ) . toBe ( 'Best close button ever' ) ;
344+ } ) ;
345+
340346 it ( 'should add a role to the dialog title' , ( ) => {
341- let header = dialogElement . querySelector ( '[md-dialog-title]' ) ;
347+ let header = overlayContainerElement . querySelector ( '[md-dialog-title]' ) ;
342348 expect ( header . getAttribute ( 'role' ) ) . toBe ( 'heading' ) ;
343349 } ) ;
344350
345351 it ( 'should add a role to the dialog content' , ( ) => {
346- let content = dialogElement . querySelector ( 'md-dialog-content' ) ;
352+ let content = overlayContainerElement . querySelector ( 'md-dialog-content' ) ;
347353 expect ( content . getAttribute ( 'role' ) ) . toBe ( 'main' ) ;
348354 } ) ;
355+
349356 } ) ;
350357} ) ;
351358
@@ -378,12 +385,14 @@ class PizzaMsg {
378385 <h1 md-dialog-title>This is the title</h1>
379386 <md-dialog-content>Lorem ipsum dolor sit amet.</md-dialog-content>
380387 <md-dialog-actions>
381- <button md-dialog-close>Close</button>
388+ <button md-dialog-close [aria-label]="closeButtonAriaLabel" >Close</button>
382389 <div md-dialog-close>Should not close</div>
383390 </md-dialog-actions>
384391 `
385392} )
386- class ContentElementDialog { }
393+ class ContentElementDialog {
394+ closeButtonAriaLabel : string ;
395+ }
387396
388397// Create a real (non-test) NgModule as a workaround for
389398// https://github.com/angular/angular/issues/10760
0 commit comments