MCPcopy Index your code
hub / github.com/angular/components / runContentElementTests

Function runContentElementTests

src/material/dialog/dialog.spec.ts:1823–1966  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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', () => {

Callers 1

dialog.spec.tsFile · 0.85

Calls 4

afterClosedMethod · 0.80
markForCheckMethod · 0.80
clickMethod · 0.65
getAttributeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…