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