@@ -25,7 +25,6 @@ import {
2525 Type ,
2626 ViewChild ,
2727 ViewChildren ,
28- provideZoneChangeDetection ,
2928} from '@angular/core' ;
3029import { ComponentFixture , fakeAsync , flush , TestBed , tick } from '@angular/core/testing' ;
3130import { MatRipple } from '@angular/material/core' ;
@@ -64,7 +63,7 @@ describe('MDC-based MatMenu', () => {
6463 declarations : any [ ] = [ ] ,
6564 ) : ComponentFixture < T > {
6665 TestBed . configureTestingModule ( {
67- providers : [ provideZoneChangeDetection ( ) , ... providers ] ,
66+ providers,
6867 imports : [ MatMenuModule , NoopAnimationsModule ] ,
6968 declarations : [ component , ...declarations ] ,
7069 } ) . compileComponents ( ) ;
@@ -96,6 +95,7 @@ describe('MDC-based MatMenu', () => {
9695 expect ( triggerElement . getAttribute ( 'aria-haspopup' ) ) . toBe ( 'menu' ) ;
9796
9897 fixture . componentInstance . trigger . menu = null ;
98+ fixture . changeDetectorRef . markForCheck ( ) ;
9999 fixture . detectChanges ( ) ;
100100
101101 expect ( triggerElement . hasAttribute ( 'aria-haspopup' ) ) . toBe ( false ) ;
@@ -371,6 +371,7 @@ describe('MDC-based MatMenu', () => {
371371
372372 // Add 50 items to make the menu scrollable
373373 fixture . componentInstance . extraItems = new Array ( 50 ) . fill ( 'Hello there' ) ;
374+ fixture . changeDetectorRef . markForCheck ( ) ;
374375 fixture . detectChanges ( ) ;
375376
376377 const triggerEl = fixture . componentInstance . triggerEl . nativeElement ;
@@ -650,6 +651,7 @@ describe('MDC-based MatMenu', () => {
650651 instance . ariaLabel = 'Custom aria-label' ;
651652 instance . ariaLabelledby = 'custom-labelled-by' ;
652653 instance . ariaDescribedby = 'custom-described-by' ;
654+ fixture . changeDetectorRef . markForCheck ( ) ;
653655 fixture . detectChanges ( ) ;
654656
655657 expect ( menuPanel . getAttribute ( 'aria-label' ) ) . toBe ( 'Custom aria-label' ) ;
@@ -658,6 +660,7 @@ describe('MDC-based MatMenu', () => {
658660
659661 // Change these to empty strings to make sure that we don't preserve empty attributes.
660662 instance . ariaLabel = instance . ariaLabelledby = instance . ariaDescribedby = '' ;
663+ fixture . changeDetectorRef . markForCheck ( ) ;
661664 fixture . detectChanges ( ) ;
662665
663666 expect ( menuPanel . hasAttribute ( 'aria-label' ) ) . toBe ( false ) ;
@@ -904,11 +907,11 @@ describe('MDC-based MatMenu', () => {
904907 } ) ) ;
905908
906909 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 / ) ;
912915 } ) ) ;
913916
914917 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', () => {
12221225 expect ( Math . floor ( panelRect . bottom ) ) . toBeLessThan ( viewportHeight ) ;
12231226
12241227 fixture . componentInstance . extraItems = new Array ( 50 ) . fill ( 'Hello there' ) ;
1228+ fixture . changeDetectorRef . markForCheck ( ) ;
12251229 fixture . detectChanges ( ) ;
12261230 panelRect = panel . getBoundingClientRect ( ) ;
12271231 expect ( Math . floor ( panelRect . bottom ) ) . toBe ( viewportHeight ) ;
@@ -1408,6 +1412,7 @@ describe('MDC-based MatMenu', () => {
14081412 trigger . style . top = '200px' ;
14091413
14101414 fixture . componentInstance . yPosition = 'above' ;
1415+ fixture . changeDetectorRef . markForCheck ( ) ;
14111416 fixture . detectChanges ( ) ;
14121417
14131418 fixture . componentInstance . trigger . openMenu ( ) ;
@@ -1425,6 +1430,7 @@ describe('MDC-based MatMenu', () => {
14251430 tick ( 500 ) ;
14261431
14271432 fixture . componentInstance . yPosition = 'below' ;
1433+ fixture . changeDetectorRef . markForCheck ( ) ;
14281434 fixture . detectChanges ( ) ;
14291435
14301436 fixture . componentInstance . trigger . openMenu ( ) ;
@@ -2499,6 +2505,7 @@ describe('MDC-based MatMenu', () => {
24992505 fixture . detectChanges ( ) ;
25002506 tick ( 500 ) ;
25012507 fixture . detectChanges ( ) ;
2508+ flush ( ) ;
25022509
25032510 expect ( lazyTrigger . classList )
25042511 . withContext ( 'Expected the trigger to be highlighted' )
@@ -2711,7 +2718,6 @@ describe('MatMenu default overrides', () => {
27112718 TestBed . configureTestingModule ( {
27122719 imports : [ MatMenuModule , NoopAnimationsModule ] ,
27132720 providers : [
2714- provideZoneChangeDetection ( ) ,
27152721 {
27162722 provide : MAT_MENU_DEFAULT_OPTIONS ,
27172723 useValue : { overlapTrigger : true , xPosition : 'before' , yPosition : 'above' } ,
0 commit comments