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 } 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
announcerSpy . calls . reset ( ) ;
294
294
fixture . componentInstance . politeness = 'off' ;
@@ -306,7 +306,7 @@ describe('CdkAriaLive', () => {
306
306
invokeMutationCallbacks ( ) ;
307
307
flush ( ) ;
308
308
309
- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' ) ;
309
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' , undefined ) ;
310
310
} ) ) ;
311
311
312
312
it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
@@ -324,6 +324,16 @@ describe('CdkAriaLive', () => {
324
324
expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
325
325
} ) ) ;
326
326
327
+ it ( 'should be able to pass in a duration' , fakeAsync ( ( ) => {
328
+ fixture . componentInstance . content = 'New content' ;
329
+ fixture . componentInstance . duration = 1337 ;
330
+ fixture . detectChanges ( ) ;
331
+ invokeMutationCallbacks ( ) ;
332
+ flush ( ) ;
333
+
334
+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , 1337 ) ;
335
+ } ) ) ;
336
+
327
337
} ) ;
328
338
329
339
@@ -340,8 +350,11 @@ class TestApp {
340
350
}
341
351
}
342
352
343
- @Component ( { template : `<div [cdkAriaLive]="politeness">{{content}}</div>` } )
353
+ @Component ( {
354
+ template : `<div [cdkAriaLive]="politeness" [cdkAriaLiveDuration]="duration">{{content}}</div>`
355
+ } )
344
356
class DivWithCdkAriaLive {
345
- @Input ( ) politeness = 'polite' ;
346
- @Input ( ) content = 'Initial content' ;
357
+ politeness = 'polite' ;
358
+ content = 'Initial content' ;
359
+ duration : number ;
347
360
}
0 commit comments