()
| 1830 | }); |
| 1831 | |
| 1832 | function runContentElementTests() { |
| 1833 | it('should close the dialog when clicking on the close button', async () => { |
| 1834 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1835 | 1, |
| 1836 | ); |
| 1837 | |
| 1838 | (overlayContainerElement.querySelector('button[mat-dialog-close]') as HTMLElement).click(); |
| 1839 | viewContainerFixture.detectChanges(); |
| 1840 | await viewContainerFixture.whenStable(); |
| 1841 | |
| 1842 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1843 | 0, |
| 1844 | ); |
| 1845 | }); |
| 1846 | |
| 1847 | it('should not close when clicking on an aria-disabled close button', async () => { |
| 1848 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1849 | 1, |
| 1850 | ); |
| 1851 | |
| 1852 | const closeButton = overlayContainerElement.querySelector( |
| 1853 | 'button[mat-dialog-close]', |
| 1854 | ) as HTMLElement; |
| 1855 | |
| 1856 | closeButton.setAttribute('aria-disabled', 'true'); |
| 1857 | closeButton.click(); |
| 1858 | viewContainerFixture.detectChanges(); |
| 1859 | await viewContainerFixture.whenStable(); |
| 1860 | |
| 1861 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1862 | 1, |
| 1863 | ); |
| 1864 | }); |
| 1865 | |
| 1866 | it('should not close if [mat-dialog-close] is applied on a non-button node', () => { |
| 1867 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1868 | 1, |
| 1869 | ); |
| 1870 | |
| 1871 | (overlayContainerElement.querySelector('div[mat-dialog-close]') as HTMLElement).click(); |
| 1872 | |
| 1873 | expect(overlayContainerElement.querySelectorAll('.mat-mdc-dialog-container').length).toBe( |
| 1874 | 1, |
| 1875 | ); |
| 1876 | }); |
| 1877 | |
| 1878 | it('should allow for a user-specified aria-label on the close button', async () => { |
| 1879 | let button = overlayContainerElement.querySelector('.close-with-aria-label')!; |
| 1880 | expect(button.getAttribute('aria-label')).toBe('Best close button ever'); |
| 1881 | }); |
| 1882 | |
| 1883 | it('should set the "type" attribute of the close button if not set manually', () => { |
| 1884 | let button = overlayContainerElement.querySelector('button[mat-dialog-close]')!; |
| 1885 | |
| 1886 | expect(button.getAttribute('type')).toBe('button'); |
| 1887 | }); |
| 1888 | |
| 1889 | it('should not override type attribute of the close button if set manually', () => { |
no test coverage detected