@@ -30,7 +30,6 @@ import {
30
30
ViewEncapsulation ,
31
31
createNgModuleRef ,
32
32
forwardRef ,
33
- provideZoneChangeDetection ,
34
33
signal ,
35
34
} from '@angular/core' ;
36
35
import {
@@ -84,8 +83,6 @@ describe('MDC-based MatDialog', () => {
84
83
ComponentWithContentElementTemplateRef ,
85
84
] ,
86
85
providers : [
87
- provideZoneChangeDetection ( ) ,
88
- provideZoneChangeDetection ( ) ,
89
86
{ provide : Location , useClass : SpyLocation } ,
90
87
{
91
88
provide : ScrollDispatcher ,
@@ -137,6 +134,7 @@ describe('MDC-based MatDialog', () => {
137
134
it ( 'should open a dialog with a template' , ( ) => {
138
135
const templateRefFixture = TestBed . createComponent ( ComponentWithTemplateRef ) ;
139
136
templateRefFixture . componentInstance . localValue = 'Bees' ;
137
+ templateRefFixture . changeDetectorRef . markForCheck ( ) ;
140
138
templateRefFixture . detectChanges ( ) ;
141
139
142
140
const data = { value : 'Knees' } ;
@@ -233,24 +231,6 @@ describe('MDC-based MatDialog', () => {
233
231
expect ( overlayContainerElement . querySelector ( 'mat-dialog-container' ) ) . toBeNull ( ) ;
234
232
} ) ) ;
235
233
236
- it ( 'should invoke the afterClosed callback inside the NgZone' , fakeAsync (
237
- inject ( [ NgZone ] , ( zone : NgZone ) => {
238
- const dialogRef = dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
239
- const afterCloseCallback = jasmine . createSpy ( 'afterClose callback' ) ;
240
-
241
- dialogRef . afterClosed ( ) . subscribe ( ( ) => {
242
- afterCloseCallback ( NgZone . isInAngularZone ( ) ) ;
243
- } ) ;
244
- zone . run ( ( ) => {
245
- dialogRef . close ( ) ;
246
- viewContainerFixture . detectChanges ( ) ;
247
- flush ( ) ;
248
- } ) ;
249
-
250
- expect ( afterCloseCallback ) . toHaveBeenCalledWith ( true ) ;
251
- } ) ,
252
- ) ) ;
253
-
254
234
it ( 'should dispose of dialog if view container is destroyed while animating' , fakeAsync ( ( ) => {
255
235
const dialogRef = dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
256
236
@@ -1077,8 +1057,8 @@ describe('MDC-based MatDialog', () => {
1077
1057
autoFocus : 'first-heading' ,
1078
1058
} ) ;
1079
1059
1060
+ flush ( ) ;
1080
1061
viewContainerFixture . detectChanges ( ) ;
1081
- flushMicrotasks ( ) ;
1082
1062
1083
1063
let backdrop = overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
1084
1064
let firstHeader = overlayContainerElement . querySelector (
@@ -1110,8 +1090,8 @@ describe('MDC-based MatDialog', () => {
1110
1090
autoFocus : 'button' ,
1111
1091
} ) ;
1112
1092
1093
+ flush ( ) ;
1113
1094
viewContainerFixture . detectChanges ( ) ;
1114
- flushMicrotasks ( ) ;
1115
1095
1116
1096
let backdrop = overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
1117
1097
let firstButton = overlayContainerElement . querySelector (
@@ -1228,8 +1208,8 @@ describe('MDC-based MatDialog', () => {
1228
1208
autoFocus : 'first-heading' ,
1229
1209
} ) ;
1230
1210
1211
+ flush ( ) ;
1231
1212
viewContainerFixture . detectChanges ( ) ;
1232
- flushMicrotasks ( ) ;
1233
1213
1234
1214
let firstHeader = overlayContainerElement . querySelector (
1235
1215
'h2[tabindex="-1"]' ,
@@ -1284,8 +1264,8 @@ describe('MDC-based MatDialog', () => {
1284
1264
dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ,
1285
1265
) ;
1286
1266
1287
- viewContainerFixture . detectChanges ( ) ;
1288
1267
flush ( ) ;
1268
+ viewContainerFixture . detectChanges ( ) ;
1289
1269
1290
1270
expect ( document . activeElement ! . id ) . not . toBe (
1291
1271
'dialog-trigger' ,
@@ -1546,8 +1526,8 @@ describe('MDC-based MatDialog', () => {
1546
1526
} ) ,
1547
1527
) ;
1548
1528
1549
- viewContainerFixture . detectChanges ( ) ;
1550
1529
flush ( ) ;
1530
+ viewContainerFixture . detectChanges ( ) ;
1551
1531
1552
1532
expect ( document . activeElement ! . id ) . not . toBe (
1553
1533
'dialog-trigger' ,
@@ -1581,8 +1561,8 @@ describe('MDC-based MatDialog', () => {
1581
1561
dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ,
1582
1562
) ;
1583
1563
1584
- viewContainerFixture . detectChanges ( ) ;
1585
1564
flush ( ) ;
1565
+ viewContainerFixture . detectChanges ( ) ;
1586
1566
1587
1567
expect ( document . activeElement ! . id ) . not . toBe (
1588
1568
'dialog-trigger' ,
@@ -1681,8 +1661,9 @@ describe('MDC-based MatDialog', () => {
1681
1661
1682
1662
const hostFixture = TestBed . createComponent ( OnPushHost ) ;
1683
1663
hostFixture . componentInstance . child . open ( ) ;
1684
- hostFixture . autoDetectChanges ( ) ;
1664
+ hostFixture . detectChanges ( ) ;
1685
1665
flush ( ) ;
1666
+ hostFixture . detectChanges ( ) ;
1686
1667
1687
1668
const overlayContainer = TestBed . inject ( OverlayContainer ) ;
1688
1669
const title = overlayContainer . getContainerElement ( ) . querySelector ( '[mat-dialog-title]' ) ! ;
@@ -1696,6 +1677,7 @@ describe('MDC-based MatDialog', () => {
1696
1677
hostFixture . componentInstance . child . dialogRef ?. componentInstance . showTitle . set ( false ) ;
1697
1678
hostFixture . detectChanges ( ) ;
1698
1679
flush ( ) ;
1680
+ hostFixture . detectChanges ( ) ;
1699
1681
expect ( container . getAttribute ( 'aria-labelledby' ) ) . toBe ( null ) ;
1700
1682
} ) ) ;
1701
1683
@@ -1779,6 +1761,7 @@ describe('MDC-based MatDialog', () => {
1779
1761
expect ( container . getAttribute ( 'aria-labelledby' ) ) . toBe ( title . id ) ;
1780
1762
1781
1763
hostInstance . shownTitle = 'second' ;
1764
+ viewContainerFixture . changeDetectorRef . markForCheck ( ) ;
1782
1765
viewContainerFixture . detectChanges ( ) ;
1783
1766
flush ( ) ;
1784
1767
viewContainerFixture . detectChanges ( ) ;
@@ -1793,6 +1776,7 @@ describe('MDC-based MatDialog', () => {
1793
1776
const container = overlayContainerElement . querySelector ( 'mat-dialog-container' ) ! ;
1794
1777
1795
1778
hostInstance . shownTitle = 'all' ;
1779
+ viewContainerFixture . changeDetectorRef . markForCheck ( ) ;
1796
1780
viewContainerFixture . detectChanges ( ) ;
1797
1781
flush ( ) ;
1798
1782
viewContainerFixture . detectChanges ( ) ;
@@ -1803,6 +1787,7 @@ describe('MDC-based MatDialog', () => {
1803
1787
expect ( container . getAttribute ( 'aria-labelledby' ) ) . toBe ( titles [ 0 ] . id ) ;
1804
1788
1805
1789
hostInstance . shownTitle = 'second' ;
1790
+ viewContainerFixture . changeDetectorRef . markForCheck ( ) ;
1806
1791
viewContainerFixture . detectChanges ( ) ;
1807
1792
flush ( ) ;
1808
1793
viewContainerFixture . detectChanges ( ) ;
@@ -1906,6 +1891,7 @@ describe('MDC-based MatDialog', () => {
1906
1891
1907
1892
dialogRef . close ( ) ;
1908
1893
viewContainerFixture . componentInstance . showChildView = false ;
1894
+ viewContainerFixture . changeDetectorRef . markForCheck ( ) ;
1909
1895
viewContainerFixture . detectChanges ( ) ;
1910
1896
flush ( ) ;
1911
1897
@@ -1923,7 +1909,6 @@ describe('MDC-based MatDialog with a parent MatDialog', () => {
1923
1909
TestBed . configureTestingModule ( {
1924
1910
imports : [ MatDialogModule , NoopAnimationsModule , ComponentThatProvidesMatDialog ] ,
1925
1911
providers : [
1926
- provideZoneChangeDetection ( ) ,
1927
1912
{
1928
1913
provide : OverlayContainer ,
1929
1914
useFactory : ( ) => {
@@ -2041,10 +2026,7 @@ describe('MDC-based MatDialog with default options', () => {
2041
2026
ComponentWithChildViewContainer ,
2042
2027
DirectiveWithViewContainer ,
2043
2028
] ,
2044
- providers : [
2045
- { provide : MAT_DIALOG_DEFAULT_OPTIONS , useValue : defaultConfig } ,
2046
- provideZoneChangeDetection ( ) ,
2047
- ] ,
2029
+ providers : [ { provide : MAT_DIALOG_DEFAULT_OPTIONS , useValue : defaultConfig } ] ,
2048
2030
} ) ;
2049
2031
2050
2032
TestBed . compileComponents ( ) ;
0 commit comments