1
1
import { MutationObserverFactory } from '@angular/cdk/observers' ;
2
- import { Component , Input } from '@angular/core' ;
2
+ import { Component } from '@angular/core' ;
3
3
import { ComponentFixture , fakeAsync , flush , inject , TestBed , tick } from '@angular/core/testing' ;
4
4
import { By } from '@angular/platform-browser' ;
5
- import { A11yModule , AriaLivePoliteness } from '../index' ;
5
+ import { A11yModule } from '../index' ;
6
6
import { LiveAnnouncer } from './live-announcer' ;
7
7
import {
8
8
LIVE_ANNOUNCER_ELEMENT_TOKEN ,
@@ -280,7 +280,7 @@ describe('CdkAriaLive', () => {
280
280
invokeMutationCallbacks ( ) ;
281
281
flush ( ) ;
282
282
283
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
283
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
284
284
} ) ) ;
285
285
286
286
it ( 'should dynamically update the politeness' , fakeAsync ( ( ) => {
@@ -289,7 +289,7 @@ describe('CdkAriaLive', () => {
289
289
invokeMutationCallbacks ( ) ;
290
290
flush ( ) ;
291
291
292
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
292
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
293
293
294
294
announcerSpy . calls . reset ( ) ;
295
295
fixture . componentInstance . politeness = 'off' ;
@@ -307,7 +307,7 @@ describe('CdkAriaLive', () => {
307
307
invokeMutationCallbacks ( ) ;
308
308
flush ( ) ;
309
309
310
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' ) ;
310
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' , undefined ) ;
311
311
} ) ) ;
312
312
313
313
it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
@@ -324,6 +324,16 @@ describe('CdkAriaLive', () => {
324
324
325
325
expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
326
326
} ) ) ;
327
+
328
+ it ( 'should be able to pass in a duration' , fakeAsync ( ( ) => {
329
+ fixture . componentInstance . content = 'New content' ;
330
+ fixture . componentInstance . duration = 1337 ;
331
+ fixture . detectChanges ( ) ;
332
+ invokeMutationCallbacks ( ) ;
333
+ flush ( ) ;
334
+
335
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , 1337 ) ;
336
+ } ) ) ;
327
337
} ) ;
328
338
329
339
function getLiveElement ( ) : Element {
@@ -339,8 +349,14 @@ class TestApp {
339
349
}
340
350
}
341
351
342
- @Component ( { template : `<div [cdkAriaLive]="politeness ? politeness : null">{{content}}</div>` } )
352
+ @Component ( {
353
+ template : `
354
+ <div
355
+ [cdkAriaLive]="politeness ? politeness : null"
356
+ [cdkAriaLiveDuration]="duration">{{content}}</div>` ,
357
+ } )
343
358
class DivWithCdkAriaLive {
344
- @Input ( ) politeness : AriaLivePoliteness ;
345
- @Input ( ) content = 'Initial content' ;
359
+ politeness = 'polite' ;
360
+ content = 'Initial content' ;
361
+ duration : number ;
346
362
}
0 commit comments