@@ -25,7 +25,6 @@ import {
25
25
Type ,
26
26
ViewChild ,
27
27
ViewChildren ,
28
- provideZoneChangeDetection ,
29
28
} from '@angular/core' ;
30
29
import { ComponentFixture , fakeAsync , flush , TestBed , tick } from '@angular/core/testing' ;
31
30
import { MatRipple } from '@angular/material/core' ;
@@ -64,7 +63,7 @@ describe('MDC-based MatMenu', () => {
64
63
declarations : any [ ] = [ ] ,
65
64
) : ComponentFixture < T > {
66
65
TestBed . configureTestingModule ( {
67
- providers : [ provideZoneChangeDetection ( ) , ... providers ] ,
66
+ providers,
68
67
imports : [ MatMenuModule , NoopAnimationsModule ] ,
69
68
declarations : [ component , ...declarations ] ,
70
69
} ) . compileComponents ( ) ;
@@ -96,6 +95,7 @@ describe('MDC-based MatMenu', () => {
96
95
expect ( triggerElement . getAttribute ( 'aria-haspopup' ) ) . toBe ( 'menu' ) ;
97
96
98
97
fixture . componentInstance . trigger . menu = null ;
98
+ fixture . changeDetectorRef . markForCheck ( ) ;
99
99
fixture . detectChanges ( ) ;
100
100
101
101
expect ( triggerElement . hasAttribute ( 'aria-haspopup' ) ) . toBe ( false ) ;
@@ -371,6 +371,7 @@ describe('MDC-based MatMenu', () => {
371
371
372
372
// Add 50 items to make the menu scrollable
373
373
fixture . componentInstance . extraItems = new Array ( 50 ) . fill ( 'Hello there' ) ;
374
+ fixture . changeDetectorRef . markForCheck ( ) ;
374
375
fixture . detectChanges ( ) ;
375
376
376
377
const triggerEl = fixture . componentInstance . triggerEl . nativeElement ;
@@ -650,6 +651,7 @@ describe('MDC-based MatMenu', () => {
650
651
instance . ariaLabel = 'Custom aria-label' ;
651
652
instance . ariaLabelledby = 'custom-labelled-by' ;
652
653
instance . ariaDescribedby = 'custom-described-by' ;
654
+ fixture . changeDetectorRef . markForCheck ( ) ;
653
655
fixture . detectChanges ( ) ;
654
656
655
657
expect ( menuPanel . getAttribute ( 'aria-label' ) ) . toBe ( 'Custom aria-label' ) ;
@@ -658,6 +660,7 @@ describe('MDC-based MatMenu', () => {
658
660
659
661
// Change these to empty strings to make sure that we don't preserve empty attributes.
660
662
instance . ariaLabel = instance . ariaLabelledby = instance . ariaDescribedby = '' ;
663
+ fixture . changeDetectorRef . markForCheck ( ) ;
661
664
fixture . detectChanges ( ) ;
662
665
663
666
expect ( menuPanel . hasAttribute ( 'aria-label' ) ) . toBe ( false ) ;
@@ -904,11 +907,11 @@ describe('MDC-based MatMenu', () => {
904
907
} ) ) ;
905
908
906
909
it ( 'should throw if assigning a menu that contains the trigger' , fakeAsync ( ( ) => {
907
- expect ( ( ) => {
908
- const fixture = createComponent ( InvalidRecursiveMenu , [ ] , [ FakeIcon ] ) ;
909
- fixture . detectChanges ( ) ;
910
- tick ( 500 ) ;
911
- } ) . toThrowError ( / m e n u c a n n o t c o n t a i n i t s o w n t r i g g e r / ) ;
910
+ const errorSpy = spyOn ( console , 'error' ) ;
911
+ const fixture = createComponent ( InvalidRecursiveMenu , [ ] , [ FakeIcon ] ) ;
912
+ fixture . detectChanges ( ) ;
913
+ tick ( 500 ) ;
914
+ expect ( errorSpy . calls . first ( ) . args [ 1 ] ) . toMatch ( / m e n u c a n n o t c o n t a i n i t s o w n t r i g g e r / ) ;
912
915
} ) ) ;
913
916
914
917
it ( 'should be able to swap out a menu after the first time it is opened' , fakeAsync ( ( ) => {
@@ -1222,6 +1225,7 @@ describe('MDC-based MatMenu', () => {
1222
1225
expect ( Math . floor ( panelRect . bottom ) ) . toBeLessThan ( viewportHeight ) ;
1223
1226
1224
1227
fixture . componentInstance . extraItems = new Array ( 50 ) . fill ( 'Hello there' ) ;
1228
+ fixture . changeDetectorRef . markForCheck ( ) ;
1225
1229
fixture . detectChanges ( ) ;
1226
1230
panelRect = panel . getBoundingClientRect ( ) ;
1227
1231
expect ( Math . floor ( panelRect . bottom ) ) . toBe ( viewportHeight ) ;
@@ -1408,6 +1412,7 @@ describe('MDC-based MatMenu', () => {
1408
1412
trigger . style . top = '200px' ;
1409
1413
1410
1414
fixture . componentInstance . yPosition = 'above' ;
1415
+ fixture . changeDetectorRef . markForCheck ( ) ;
1411
1416
fixture . detectChanges ( ) ;
1412
1417
1413
1418
fixture . componentInstance . trigger . openMenu ( ) ;
@@ -1425,6 +1430,7 @@ describe('MDC-based MatMenu', () => {
1425
1430
tick ( 500 ) ;
1426
1431
1427
1432
fixture . componentInstance . yPosition = 'below' ;
1433
+ fixture . changeDetectorRef . markForCheck ( ) ;
1428
1434
fixture . detectChanges ( ) ;
1429
1435
1430
1436
fixture . componentInstance . trigger . openMenu ( ) ;
@@ -2499,6 +2505,7 @@ describe('MDC-based MatMenu', () => {
2499
2505
fixture . detectChanges ( ) ;
2500
2506
tick ( 500 ) ;
2501
2507
fixture . detectChanges ( ) ;
2508
+ flush ( ) ;
2502
2509
2503
2510
expect ( lazyTrigger . classList )
2504
2511
. withContext ( 'Expected the trigger to be highlighted' )
@@ -2711,7 +2718,6 @@ describe('MatMenu default overrides', () => {
2711
2718
TestBed . configureTestingModule ( {
2712
2719
imports : [ MatMenuModule , NoopAnimationsModule ] ,
2713
2720
providers : [
2714
- provideZoneChangeDetection ( ) ,
2715
2721
{
2716
2722
provide : MAT_MENU_DEFAULT_OPTIONS ,
2717
2723
useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
0 commit comments