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