dialog.spec.ts (material2-7.3.2) | : | dialog.spec.ts (material2-7.3.3) | ||
---|---|---|---|---|
skipping to change at line 1144 | skipping to change at line 1144 | |||
})); | })); | |||
it('should not close if [mat-dialog-close] is applied on a non-button node ', () => { | it('should not close if [mat-dialog-close] is applied on a non-button node ', () => { | |||
expect(overlayContainerElement.querySelectorAll('.mat-dialog-container') .length).toBe(1); | expect(overlayContainerElement.querySelectorAll('.mat-dialog-container') .length).toBe(1); | |||
(overlayContainerElement.querySelector('div[mat-dialog-close]') as HTMLE lement).click(); | (overlayContainerElement.querySelector('div[mat-dialog-close]') as HTMLE lement).click(); | |||
expect(overlayContainerElement.querySelectorAll('.mat-dialog-container') .length).toBe(1); | expect(overlayContainerElement.querySelectorAll('.mat-dialog-container') .length).toBe(1); | |||
}); | }); | |||
it('should set an aria-label on a button without text', fakeAsync(() => { | ||||
let button = overlayContainerElement.querySelector('.close-without-text' | ||||
)!; | ||||
expect(button.getAttribute('aria-label')).toBeTruthy(); | ||||
})); | ||||
it('should not have an aria-label if a button has text', fakeAsync(() => { | ||||
let button = overlayContainerElement.querySelector('[mat-dialog-close]') | ||||
!; | ||||
expect(button.getAttribute('aria-label')).toBeFalsy(); | ||||
})); | ||||
it('should allow for a user-specified aria-label on the close button', fak eAsync(() => { | it('should allow for a user-specified aria-label on the close button', fak eAsync(() => { | |||
let button = overlayContainerElement.querySelector('.close-with-aria-lab el')!; | let button = overlayContainerElement.querySelector('.close-with-aria-lab el')!; | |||
expect(button.getAttribute('aria-label')).toBe('Best close button ever') ; | expect(button.getAttribute('aria-label')).toBe('Best close button ever') ; | |||
})); | })); | |||
it('should always have an aria-label on a mat-icon-button', fakeAsync(() = | ||||
> { | ||||
let button = overlayContainerElement.querySelector('.close-icon-button') | ||||
!; | ||||
expect(button.getAttribute('aria-label')).toBeTruthy(); | ||||
})); | ||||
it('should override the "type" attribute of the close button', () => { | it('should override the "type" attribute of the close button', () => { | |||
let button = overlayContainerElement.querySelector('button[mat-dialog-cl ose]')!; | let button = overlayContainerElement.querySelector('button[mat-dialog-cl ose]')!; | |||
expect(button.getAttribute('type')).toBe('button'); | expect(button.getAttribute('type')).toBe('button'); | |||
}); | }); | |||
it('should return the [mat-dialog-close] result when clicking the close bu tton', | it('should return the [mat-dialog-close] result when clicking the close bu tton', | |||
fakeAsync(() => { | fakeAsync(() => { | |||
let afterCloseCallback = jasmine.createSpy('afterClose callback'); | let afterCloseCallback = jasmine.createSpy('afterClose callback'); | |||
dialogRef.afterClosed().subscribe(afterCloseCallback); | dialogRef.afterClosed().subscribe(afterCloseCallback); | |||
skipping to change at line 1448 | skipping to change at line 1463 | |||
public dialogInjector: Injector, | public dialogInjector: Injector, | |||
public directionality: Directionality) {} | public directionality: Directionality) {} | |||
} | } | |||
@Component({ | @Component({ | |||
template: ` | template: ` | |||
<h1 mat-dialog-title>This is the title</h1> | <h1 mat-dialog-title>This is the title</h1> | |||
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content> | <mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content> | |||
<mat-dialog-actions> | <mat-dialog-actions> | |||
<button mat-dialog-close>Close</button> | <button mat-dialog-close>Close</button> | |||
<button class="close-without-text" mat-dialog-close></button> | ||||
<button class="close-icon-button" mat-icon-button mat-dialog-close>exit</b | ||||
utton> | ||||
<button class="close-with-true" [mat-dialog-close]="true">Close and return true</button> | <button class="close-with-true" [mat-dialog-close]="true">Close and return true</button> | |||
<button | <button | |||
class="close-with-aria-label" | class="close-with-aria-label" | |||
aria-label="Best close button ever" | aria-label="Best close button ever" | |||
[mat-dialog-close]="true">Close</button> | [mat-dialog-close]="true"></button> | |||
<div mat-dialog-close>Should not close</div> | <div mat-dialog-close>Should not close</div> | |||
</mat-dialog-actions> | </mat-dialog-actions> | |||
` | ` | |||
}) | }) | |||
class ContentElementDialog {} | class ContentElementDialog {} | |||
@Component({ | @Component({ | |||
template: ` | template: ` | |||
<ng-template> | <ng-template> | |||
<h1 mat-dialog-title>This is the title</h1> | <h1 mat-dialog-title>This is the title</h1> | |||
<mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content> | <mat-dialog-content>Lorem ipsum dolor sit amet.</mat-dialog-content> | |||
<mat-dialog-actions> | <mat-dialog-actions> | |||
<button mat-dialog-close>Close</button> | <button mat-dialog-close>Close</button> | |||
<button class="close-without-text" mat-dialog-close></button> | ||||
<button class="close-icon-button" mat-icon-button mat-dialog-close>exit< | ||||
/button> | ||||
<button class="close-with-true" [mat-dialog-close]="true">Close and retu rn true</button> | <button class="close-with-true" [mat-dialog-close]="true">Close and retu rn true</button> | |||
<button | <button | |||
class="close-with-aria-label" | class="close-with-aria-label" | |||
aria-label="Best close button ever" | aria-label="Best close button ever" | |||
[mat-dialog-close]="true">Close</button> | [mat-dialog-close]="true"></button> | |||
<div mat-dialog-close>Should not close</div> | <div mat-dialog-close>Should not close</div> | |||
</mat-dialog-actions> | </mat-dialog-actions> | |||
</ng-template> | </ng-template> | |||
` | ` | |||
}) | }) | |||
class ComponentWithContentElementTemplateRef { | class ComponentWithContentElementTemplateRef { | |||
@ViewChild(TemplateRef) templateRef: TemplateRef<any>; | @ViewChild(TemplateRef) templateRef: TemplateRef<any>; | |||
} | } | |||
@Component({ | @Component({ | |||
End of changes. 6 change blocks. | ||||
2 lines changed or deleted | 27 lines changed or added |