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' ;
5- import { A11yModule , AriaLivePoliteness } from '../index' ;
5+ import { A11yModule } from '../index' ;
66import { LiveAnnouncer } from './live-announcer' ;
77import {
88 LIVE_ANNOUNCER_ELEMENT_TOKEN ,
@@ -280,7 +280,7 @@ describe('CdkAriaLive', () => {
280280 invokeMutationCallbacks ( ) ;
281281 flush ( ) ;
282282
283- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
283+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
284284 } ) ) ;
285285
286286 it ( 'should dynamically update the politeness' , fakeAsync ( ( ) => {
@@ -289,7 +289,7 @@ describe('CdkAriaLive', () => {
289289 invokeMutationCallbacks ( ) ;
290290 flush ( ) ;
291291
292- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' ) ;
292+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'New content' , 'polite' , undefined ) ;
293293
294294 announcerSpy . calls . reset ( ) ;
295295 fixture . componentInstance . politeness = 'off' ;
@@ -307,7 +307,7 @@ describe('CdkAriaLive', () => {
307307 invokeMutationCallbacks ( ) ;
308308 flush ( ) ;
309309
310- expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' ) ;
310+ expect ( announcer . announce ) . toHaveBeenCalledWith ( 'Newest content' , 'assertive' , undefined ) ;
311311 } ) ) ;
312312
313313 it ( 'should not announce the same text multiple times' , fakeAsync ( ( ) => {
@@ -324,6 +324,16 @@ describe('CdkAriaLive', () => {
324324
325325 expect ( announcer . announce ) . toHaveBeenCalledTimes ( 1 ) ;
326326 } ) ) ;
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+ } ) ) ;
327337} ) ;
328338
329339function getLiveElement ( ) : Element {
@@ -339,8 +349,14 @@ class TestApp {
339349 }
340350}
341351
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+ } )
343358class DivWithCdkAriaLive {
344- @Input ( ) politeness : AriaLivePoliteness ;
345- @Input ( ) content = 'Initial content' ;
359+ politeness = 'polite' ;
360+ content = 'Initial content' ;
361+ duration : number ;
346362}
0 commit comments