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
5
import { A11yModule , AriaLivePoliteness } from '../index' ;
@@ -288,7 +288,7 @@ describe('CdkAriaLive', () => {
288
288
invokeMutationCallbacks ( ) ;
289
289
flush ( ) ;
290
290
291
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
291
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
292
292
} ) ) ;
293
293
294
294
it ( 'should dynamically update the politeness' , fakeAsync ( ( ) => {
@@ -297,7 +297,7 @@ describe('CdkAriaLive', () => {
297
297
invokeMutationCallbacks ( ) ;
298
298
flush ( ) ;
299
299
300
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
300
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
301
301
302
302
announcerSpy . calls . reset ( ) ;
303
303
fixture . componentInstance . politeness = 'off' ;
@@ -315,7 +315,7 @@ describe('CdkAriaLive', () => {
315
315
invokeMutationCallbacks ( ) ;
316
316
flush ( ) ;
317
317
318
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' ) ;
318
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' , undefined ) ;
319
319
} ) ) ;
320
320
321
321
it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
@@ -333,6 +333,16 @@ describe('CdkAriaLive', () => {
333
333
expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
334
334
} ) ) ;
335
335
336
+ it ( 'should be able to pass in a duration' , fakeAsync ( ( ) => {
337
+ fixture . componentInstance . content = 'New content' ;
338
+ fixture . componentInstance . duration = 1337 ;
339
+ fixture . detectChanges ( ) ;
340
+ invokeMutationCallbacks ( ) ;
341
+ flush ( ) ;
342
+
343
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , 1337 ) ;
344
+ } ) ) ;
345
+
336
346
} ) ;
337
347
338
348
@@ -349,8 +359,14 @@ class TestApp {
349
359
}
350
360
}
351
361
352
- @Component ( { template : `<div [cdkAriaLive]="politeness ? politeness : null">{{content}}</div>` } )
362
+ @Component ( {
363
+ template : `
364
+ <div
365
+ [cdkAriaLive]="politeness ? politeness : null"
366
+ [cdkAriaLiveDuration]="duration">{{content}}</div>`
367
+ } )
353
368
class DivWithCdkAriaLive {
354
- @Input ( ) politeness : AriaLivePoliteness ;
355
- @Input ( ) content = 'Initial content' ;
369
+ politeness = 'polite' ;
370
+ content = 'Initial content' ;
371
+ duration : number ;
356
372
}
0 commit comments