@@ -615,8 +615,8 @@ describe('MDC-based MatDialog', () => {
615
615
616
616
it ( 'should close all of the dialogs' , fakeAsync ( ( ) => {
617
617
dialog . open ( PizzaMsg ) ;
618
- dialog . open ( PizzaMsg ) ;
619
- dialog . open ( PizzaMsg ) ;
618
+ dialog . open ( PizzaMsgTwo ) ;
619
+ dialog . open ( PizzaMsgThree ) ;
620
620
621
621
expect ( overlayContainerElement . querySelectorAll ( 'mat-dialog-container' ) . length ) . toBe ( 3 ) ;
622
622
@@ -629,7 +629,7 @@ describe('MDC-based MatDialog', () => {
629
629
630
630
it ( 'should close all dialogs when the user goes forwards/backwards in history' , fakeAsync ( ( ) => {
631
631
dialog . open ( PizzaMsg ) ;
632
- dialog . open ( PizzaMsg ) ;
632
+ dialog . open ( PizzaMsgTwo ) ;
633
633
634
634
expect ( overlayContainerElement . querySelectorAll ( 'mat-dialog-container' ) . length ) . toBe ( 2 ) ;
635
635
@@ -642,7 +642,7 @@ describe('MDC-based MatDialog', () => {
642
642
643
643
it ( 'should close all open dialogs when the location hash changes' , fakeAsync ( ( ) => {
644
644
dialog . open ( PizzaMsg ) ;
645
- dialog . open ( PizzaMsg ) ;
645
+ dialog . open ( PizzaMsgTwo ) ;
646
646
647
647
expect ( overlayContainerElement . querySelectorAll ( 'mat-dialog-container' ) . length ) . toBe ( 2 ) ;
648
648
@@ -655,8 +655,8 @@ describe('MDC-based MatDialog', () => {
655
655
656
656
it ( 'should close all of the dialogs when the injectable is destroyed' , fakeAsync ( ( ) => {
657
657
dialog . open ( PizzaMsg ) ;
658
- dialog . open ( PizzaMsg ) ;
659
- dialog . open ( PizzaMsg ) ;
658
+ dialog . open ( PizzaMsgTwo ) ;
659
+ dialog . open ( PizzaMsgThree ) ;
660
660
661
661
expect ( overlayContainerElement . querySelectorAll ( 'mat-dialog-container' ) . length ) . toBe ( 3 ) ;
662
662
@@ -685,7 +685,7 @@ describe('MDC-based MatDialog', () => {
685
685
686
686
it ( 'should allow the consumer to disable closing a dialog on navigation' , fakeAsync ( ( ) => {
687
687
dialog . open ( PizzaMsg ) ;
688
- dialog . open ( PizzaMsg , { closeOnNavigation : false } ) ;
688
+ dialog . open ( PizzaMsgTwo , { closeOnNavigation : false } ) ;
689
689
690
690
expect ( overlayContainerElement . querySelectorAll ( 'mat-dialog-container' ) . length ) . toBe ( 2 ) ;
691
691
@@ -774,7 +774,7 @@ describe('MDC-based MatDialog', () => {
774
774
775
775
it ( 'should assign a unique id to each dialog' , ( ) => {
776
776
const one = dialog . open ( PizzaMsg ) ;
777
- const two = dialog . open ( PizzaMsg ) ;
777
+ const two = dialog . open ( PizzaMsgTwo ) ;
778
778
779
779
expect ( one . id ) . toBeTruthy ( ) ;
780
780
expect ( two . id ) . toBeTruthy ( ) ;
@@ -1188,7 +1188,7 @@ describe('MDC-based MatDialog', () => {
1188
1188
expect ( document . activeElement ! . id )
1189
1189
. not . toBe (
1190
1190
'dialog-trigger' ,
1191
- 'Expcted the focus not to have changed before the animation finishes.' ) ;
1191
+ 'Expected the focus not to have changed before the animation finishes.' ) ;
1192
1192
1193
1193
flushMicrotasks ( ) ;
1194
1194
viewContainerFixture . detectChanges ( ) ;
@@ -1247,7 +1247,8 @@ describe('MDC-based MatDialog', () => {
1247
1247
1248
1248
tick ( 500 ) ;
1249
1249
viewContainerFixture . detectChanges ( ) ;
1250
- expect ( lastFocusOrigin ! ) . toBeNull ( 'Expected the trigger button to be blurred' ) ;
1250
+ expect ( lastFocusOrigin ! )
1251
+ . withContext ( 'Expected the trigger button to be blurred' ) . toBeNull ( ) ;
1251
1252
1252
1253
dispatchKeyboardEvent ( document . body , 'keydown' , ESCAPE ) ;
1253
1254
@@ -1256,7 +1257,8 @@ describe('MDC-based MatDialog', () => {
1256
1257
tick ( 500 ) ;
1257
1258
1258
1259
expect ( lastFocusOrigin ! )
1259
- . toBe ( 'keyboard' , 'Expected the trigger button to be focused via keyboard' ) ;
1260
+ . withContext ( 'Expected the trigger button to be focused via keyboard' )
1261
+ . toBe ( 'keyboard' ) ;
1260
1262
1261
1263
focusMonitor . stopMonitoring ( button ) ;
1262
1264
document . body . removeChild ( button ) ;
@@ -1281,7 +1283,8 @@ describe('MDC-based MatDialog', () => {
1281
1283
1282
1284
tick ( 500 ) ;
1283
1285
viewContainerFixture . detectChanges ( ) ;
1284
- expect ( lastFocusOrigin ! ) . toBeNull ( 'Expected the trigger button to be blurred' ) ;
1286
+ expect ( lastFocusOrigin ! )
1287
+ . withContext ( 'Expected the trigger button to be blurred' ) . toBeNull ( ) ;
1285
1288
1286
1289
const backdrop =
1287
1290
overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) as HTMLElement ;
@@ -1291,7 +1294,8 @@ describe('MDC-based MatDialog', () => {
1291
1294
tick ( 500 ) ;
1292
1295
1293
1296
expect ( lastFocusOrigin ! )
1294
- . toBe ( 'mouse' , 'Expected the trigger button to be focused via mouse' ) ;
1297
+ . withContext ( 'Expected the trigger button to be focused via mouse' )
1298
+ . toBe ( 'mouse' ) ;
1295
1299
1296
1300
focusMonitor . stopMonitoring ( button ) ;
1297
1301
document . body . removeChild ( button ) ;
@@ -1317,7 +1321,8 @@ describe('MDC-based MatDialog', () => {
1317
1321
1318
1322
tick ( 500 ) ;
1319
1323
viewContainerFixture . detectChanges ( ) ;
1320
- expect ( lastFocusOrigin ! ) . toBeNull ( 'Expected the trigger button to be blurred' ) ;
1324
+ expect ( lastFocusOrigin ! )
1325
+ . withContext ( 'Expected the trigger button to be blurred' ) . toBeNull ( ) ;
1321
1326
1322
1327
const closeButton =
1323
1328
overlayContainerElement . querySelector ( 'button[mat-dialog-close]' ) as HTMLElement ;
@@ -1330,7 +1335,8 @@ describe('MDC-based MatDialog', () => {
1330
1335
tick ( 500 ) ;
1331
1336
1332
1337
expect ( lastFocusOrigin ! )
1333
- . toBe ( 'keyboard' , 'Expected the trigger button to be focused via keyboard' ) ;
1338
+ . withContext ( 'Expected the trigger button to be focused via keyboard' )
1339
+ . toBe ( 'keyboard' ) ;
1334
1340
1335
1341
focusMonitor . stopMonitoring ( button ) ;
1336
1342
document . body . removeChild ( button ) ;
@@ -1355,7 +1361,8 @@ describe('MDC-based MatDialog', () => {
1355
1361
1356
1362
tick ( 500 ) ;
1357
1363
viewContainerFixture . detectChanges ( ) ;
1358
- expect ( lastFocusOrigin ! ) . toBeNull ( 'Expected the trigger button to be blurred' ) ;
1364
+ expect ( lastFocusOrigin ! )
1365
+ . withContext ( 'Expected the trigger button to be blurred' ) . toBeNull ( ) ;
1359
1366
1360
1367
const closeButton =
1361
1368
overlayContainerElement . querySelector ( 'button[mat-dialog-close]' ) as HTMLElement ;
@@ -1369,7 +1376,8 @@ describe('MDC-based MatDialog', () => {
1369
1376
tick ( 500 ) ;
1370
1377
1371
1378
expect ( lastFocusOrigin ! )
1372
- . toBe ( 'mouse' , 'Expected the trigger button to be focused via mouse' ) ;
1379
+ . withContext ( 'Expected the trigger button to be focused via mouse' )
1380
+ . toBe ( 'mouse' ) ;
1373
1381
1374
1382
focusMonitor . stopMonitoring ( button ) ;
1375
1383
document . body . removeChild ( button ) ;
@@ -1959,12 +1967,26 @@ class ComponentWithTemplateRef {
1959
1967
}
1960
1968
}
1961
1969
1962
- /** Simple component for testing ComponentPortal. */
1970
+ /** Simple components for testing ComponentPortal and multiple dialogs . */
1963
1971
@Component ( { template : '<p>Pizza</p> <input> <button>Close</button>' } )
1964
1972
class PizzaMsg {
1965
- constructor (
1966
- public dialogRef : MatDialogRef < PizzaMsg > , public dialogInjector : Injector ,
1967
- public directionality : Directionality ) { }
1973
+ constructor ( public dialogRef : MatDialogRef < PizzaMsg > ,
1974
+ public dialogInjector : Injector ,
1975
+ public directionality : Directionality ) { }
1976
+ }
1977
+
1978
+ @Component ( { template : '<p>Pizza</p> <input> <button>Close</button>' } )
1979
+ class PizzaMsgTwo {
1980
+ constructor ( public dialogRef : MatDialogRef < PizzaMsgTwo > ,
1981
+ public dialogInjector : Injector ,
1982
+ public directionality : Directionality ) { }
1983
+ }
1984
+
1985
+ @Component ( { template : '<p>Pizza</p> <input> <button>Close</button>' } )
1986
+ class PizzaMsgThree {
1987
+ constructor ( public dialogRef : MatDialogRef < PizzaMsgThree > ,
1988
+ public dialogInjector : Injector ,
1989
+ public directionality : Directionality ) { }
1968
1990
}
1969
1991
1970
1992
@Component ( {
@@ -2035,6 +2057,8 @@ const TEST_DIRECTIVES = [
2035
2057
ComponentWithChildViewContainer ,
2036
2058
ComponentWithTemplateRef ,
2037
2059
PizzaMsg ,
2060
+ PizzaMsgTwo ,
2061
+ PizzaMsgThree ,
2038
2062
DirectiveWithViewContainer ,
2039
2063
ComponentWithOnPushViewContainer ,
2040
2064
ContentElementDialog ,
@@ -2052,6 +2076,8 @@ const TEST_DIRECTIVES = [
2052
2076
ComponentWithChildViewContainer ,
2053
2077
ComponentWithTemplateRef ,
2054
2078
PizzaMsg ,
2079
+ PizzaMsgTwo ,
2080
+ PizzaMsgThree ,
2055
2081
ContentElementDialog ,
2056
2082
DialogWithInjectedData ,
2057
2083
DialogWithoutFocusableElements ,
0 commit comments