11import { MutationObserverFactory } from '@angular/cdk/observers' ;
2- import { Component , Input } from '@angular/core' ;
2+ import { Component } from '@angular/core' ;
33import { ComponentFixture , fakeAsync , flush , inject , TestBed , tick } from '@angular/core/testing' ;
44import { By } from '@angular/platform-browser' ;
55import { A11yModule , AriaLivePoliteness } from '../index' ;
@@ -288,7 +288,7 @@ describe('CdkAriaLive', () => {
288288 invokeMutationCallbacks ( ) ;
289289 flush ( ) ;
290290
291- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
291+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
292292 } ) ) ;
293293
294294 it ( 'should dynamically update the politeness' , fakeAsync ( ( ) => {
@@ -297,7 +297,7 @@ describe('CdkAriaLive', () => {
297297 invokeMutationCallbacks ( ) ;
298298 flush ( ) ;
299299
300- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
300+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
301301
302302 announcerSpy . calls . reset ( ) ;
303303 fixture . componentInstance . politeness = 'off' ;
@@ -315,7 +315,7 @@ describe('CdkAriaLive', () => {
315315 invokeMutationCallbacks ( ) ;
316316 flush ( ) ;
317317
318- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' ) ;
318+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' , undefined ) ;
319319 } ) ) ;
320320
321321 it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
@@ -333,6 +333,16 @@ describe('CdkAriaLive', () => {
333333 expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
334334 } ) ) ;
335335
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+
336346} ) ;
337347
338348
@@ -349,8 +359,14 @@ class TestApp {
349359 }
350360}
351361
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+ } )
353368class DivWithCdkAriaLive {
354- @Input ( ) politeness : AriaLivePoliteness ;
355- @Input ( ) content = 'Initial content' ;
369+ politeness = 'polite' ;
370+ content = 'Initial content' ;
371+ duration : number ;
356372}
0 commit comments