1
1
import { MutationObserverFactory } from '@angular/cdk/observers' ;
2
2
import { Overlay } from '@angular/cdk/overlay' ;
3
3
import { ComponentPortal } from '@angular/cdk/portal' ;
4
- import { Component , provideZoneChangeDetection } from '@angular/core' ;
5
- import { ComponentFixture , fakeAsync , flush , inject , TestBed , tick } from '@angular/core/testing' ;
4
+ import { Component } from '@angular/core' ;
5
+ import { ComponentFixture , TestBed , fakeAsync , flush , inject , tick } from '@angular/core/testing' ;
6
6
import { By } from '@angular/platform-browser' ;
7
7
import { A11yModule } from '../index' ;
8
8
import { LiveAnnouncer } from './live-announcer' ;
@@ -21,7 +21,6 @@ describe('LiveAnnouncer', () => {
21
21
describe ( 'with default element' , ( ) => {
22
22
beforeEach ( ( ) =>
23
23
TestBed . configureTestingModule ( {
24
- providers : [ provideZoneChangeDetection ( ) ] ,
25
24
imports : [ A11yModule , TestApp , TestModal ] ,
26
25
} ) ,
27
26
) ;
@@ -128,7 +127,6 @@ describe('LiveAnnouncer', () => {
128
127
fixture . destroy ( ) ;
129
128
130
129
TestBed . resetTestingModule ( ) . configureTestingModule ( {
131
- providers : [ provideZoneChangeDetection ( ) ] ,
132
130
imports : [ A11yModule ] ,
133
131
} ) ;
134
132
@@ -180,6 +178,7 @@ describe('LiveAnnouncer', () => {
180
178
const overlayRef = overlay . create ( ) ;
181
179
const componentRef = overlayRef . attach ( portal ) ;
182
180
const modal = componentRef . location . nativeElement ;
181
+ fixture . changeDetectorRef . markForCheck ( ) ;
183
182
fixture . detectChanges ( ) ;
184
183
185
184
expect ( ariaLiveElement . id ) . toBeTruthy ( ) ;
@@ -200,6 +199,7 @@ describe('LiveAnnouncer', () => {
200
199
const overlayRef = overlay . create ( ) ;
201
200
const componentRef = overlayRef . attach ( portal ) ;
202
201
const modal = componentRef . location . nativeElement ;
202
+ fixture . changeDetectorRef . markForCheck ( ) ;
203
203
fixture . detectChanges ( ) ;
204
204
205
205
componentRef . instance . ariaOwns = 'foo bar' ;
@@ -227,10 +227,7 @@ describe('LiveAnnouncer', () => {
227
227
228
228
return TestBed . configureTestingModule ( {
229
229
imports : [ A11yModule , TestApp ] ,
230
- providers : [
231
- provideZoneChangeDetection ( ) ,
232
- { provide : LIVE_ANNOUNCER_ELEMENT_TOKEN , useValue : customLiveElement } ,
233
- ] ,
230
+ providers : [ { provide : LIVE_ANNOUNCER_ELEMENT_TOKEN , useValue : customLiveElement } ] ,
234
231
} ) ;
235
232
} ) ;
236
233
@@ -254,7 +251,6 @@ describe('LiveAnnouncer', () => {
254
251
return TestBed . configureTestingModule ( {
255
252
imports : [ A11yModule , TestApp ] ,
256
253
providers : [
257
- provideZoneChangeDetection ( ) ,
258
254
{
259
255
provide : LIVE_ANNOUNCER_DEFAULT_OPTIONS ,
260
256
useValue : {
@@ -303,7 +299,6 @@ describe('CdkAriaLive', () => {
303
299
TestBed . configureTestingModule ( {
304
300
imports : [ A11yModule , DivWithCdkAriaLive ] ,
305
301
providers : [
306
- provideZoneChangeDetection ( ) ,
307
302
{
308
303
provide : MutationObserverFactory ,
309
304
useValue : {
@@ -325,13 +320,15 @@ describe('CdkAriaLive', () => {
325
320
announcer = la ;
326
321
announcerSpy = spyOn ( la , 'announce' ) . and . callThrough ( ) ;
327
322
fixture = TestBed . createComponent ( DivWithCdkAriaLive ) ;
323
+ fixture . changeDetectorRef . markForCheck ( ) ;
328
324
fixture . detectChanges ( ) ;
329
325
flush ( ) ;
330
326
} ) ,
331
327
) ) ;
332
328
333
329
it ( 'should default politeness to polite' , fakeAsync ( ( ) => {
334
330
fixture . componentInstance . content = 'New content' ;
331
+ fixture . changeDetectorRef . markForCheck ( ) ;
335
332
fixture . detectChanges ( ) ;
336
333
invokeMutationCallbacks ( ) ;
337
334
flush ( ) ;
@@ -341,6 +338,7 @@ describe('CdkAriaLive', () => {
341
338
342
339
it ( 'should dynamically update the politeness' , fakeAsync ( ( ) => {
343
340
fixture . componentInstance . content = 'New content' ;
341
+ fixture . changeDetectorRef . markForCheck ( ) ;
344
342
fixture . detectChanges ( ) ;
345
343
invokeMutationCallbacks ( ) ;
346
344
flush ( ) ;
@@ -350,6 +348,7 @@ describe('CdkAriaLive', () => {
350
348
announcerSpy . calls . reset ( ) ;
351
349
fixture . componentInstance . politeness = 'off' ;
352
350
fixture . componentInstance . content = 'Newer content' ;
351
+ fixture . changeDetectorRef . markForCheck ( ) ;
353
352
fixture . detectChanges ( ) ;
354
353
invokeMutationCallbacks ( ) ;
355
354
flush ( ) ;
@@ -359,6 +358,7 @@ describe('CdkAriaLive', () => {
359
358
announcerSpy . calls . reset ( ) ;
360
359
fixture . componentInstance . politeness = 'assertive' ;
361
360
fixture . componentInstance . content = 'Newest content' ;
361
+ fixture . changeDetectorRef . markForCheck ( ) ;
362
362
fixture . detectChanges ( ) ;
363
363
invokeMutationCallbacks ( ) ;
364
364
flush ( ) ;
@@ -368,12 +368,14 @@ describe('CdkAriaLive', () => {
368
368
369
369
it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
370
370
fixture . componentInstance . content = 'Content' ;
371
+ fixture . changeDetectorRef . markForCheck ( ) ;
371
372
fixture . detectChanges ( ) ;
372
373
invokeMutationCallbacks ( ) ;
373
374
flush ( ) ;
374
375
375
376
expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
376
377
378
+ fixture . changeDetectorRef . markForCheck ( ) ;
377
379
fixture . detectChanges ( ) ;
378
380
invokeMutationCallbacks ( ) ;
379
381
flush ( ) ;
@@ -384,6 +386,7 @@ describe('CdkAriaLive', () => {
384
386
it ( 'should be able to pass in a duration' , fakeAsync ( ( ) => {
385
387
fixture . componentInstance . content = 'New content' ;
386
388
fixture . componentInstance . duration = 1337 ;
389
+ fixture . changeDetectorRef . markForCheck ( ) ;
387
390
fixture . detectChanges ( ) ;
388
391
invokeMutationCallbacks ( ) ;
389
392
flush ( ) ;
0 commit comments