@@ -59,6 +59,7 @@ import {
59
59
import { MatFormFieldModule } from '@angular/material/form-field' ;
60
60
import { By } from '@angular/platform-browser' ;
61
61
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
62
+ import { LiveAnnouncer } from '@angular/cdk/a11y' ;
62
63
import { Subject , Subscription , EMPTY , Observable } from 'rxjs' ;
63
64
import { map } from 'rxjs/operators' ;
64
65
import { MatSelectModule } from './index' ;
@@ -291,6 +292,8 @@ describe('MatSelect', () => {
291
292
expect ( options [ 1 ] . selected ) . toBe ( true , 'Expected second option to be selected.' ) ;
292
293
expect ( formControl . value ) . toBe ( options [ 1 ] . value ,
293
294
'Expected value from second option to have been set on the model.' ) ;
295
+
296
+ flush ( ) ;
294
297
} ) ) ;
295
298
296
299
it ( 'should select first/last options via the HOME/END keys on a closed select' ,
@@ -314,6 +317,8 @@ describe('MatSelect', () => {
314
317
expect ( firstOption . selected ) . toBe ( true , 'Expected first option to be selected.' ) ;
315
318
expect ( formControl . value ) . toBe ( firstOption . value ,
316
319
'Expected value from first option to have been set on the model.' ) ;
320
+
321
+ flush ( ) ;
317
322
} ) ) ;
318
323
319
324
it ( 'should resume focus from selected item after selecting via click' , fakeAsync ( ( ) => {
@@ -336,6 +341,7 @@ describe('MatSelect', () => {
336
341
fixture . detectChanges ( ) ;
337
342
338
343
expect ( formControl . value ) . toBe ( options [ 4 ] . value ) ;
344
+ flush ( ) ;
339
345
} ) ) ;
340
346
341
347
it ( 'should select options via LEFT/RIGHT arrow keys on a closed select' , fakeAsync ( ( ) => {
@@ -363,8 +369,20 @@ describe('MatSelect', () => {
363
369
expect ( options [ 1 ] . selected ) . toBe ( true , 'Expected second option to be selected.' ) ;
364
370
expect ( formControl . value ) . toBe ( options [ 1 ] . value ,
365
371
'Expected value from second option to have been set on the model.' ) ;
372
+ flush ( ) ;
366
373
} ) ) ;
367
374
375
+ it ( 'should announce changes via the keyboard on a closed select' ,
376
+ fakeAsync ( inject ( [ LiveAnnouncer ] , ( liveAnnouncer : LiveAnnouncer ) => {
377
+ spyOn ( liveAnnouncer , 'announce' ) ;
378
+
379
+ dispatchKeyboardEvent ( select , 'keydown' , RIGHT_ARROW ) ;
380
+
381
+ expect ( liveAnnouncer . announce ) . toHaveBeenCalledWith ( 'Steak' ) ;
382
+
383
+ flush ( ) ;
384
+ } ) ) ) ;
385
+
368
386
it ( 'should open a single-selection select using ALT + DOWN_ARROW' , fakeAsync ( ( ) => {
369
387
const { control : formControl , select : selectInstance } = fixture . componentInstance ;
370
388
@@ -534,6 +552,7 @@ describe('MatSelect', () => {
534
552
535
553
expect ( formControl . value ) . toBe ( 'pasta-6' ) ;
536
554
expect ( fixture . componentInstance . options . toArray ( ) [ 6 ] . selected ) . toBe ( true ) ;
555
+ flush ( ) ;
537
556
} ) ) ;
538
557
539
558
it ( 'should not shift focus when the selected options are updated programmatically ' +
@@ -583,6 +602,8 @@ describe('MatSelect', () => {
583
602
dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
584
603
585
604
expect ( lastOption . selected ) . toBe ( true , 'Expected last option to stay selected.' ) ;
605
+
606
+ flush ( ) ;
586
607
} ) ) ;
587
608
588
609
it ( 'should not open a multiple select when tabbing through' , fakeAsync ( ( ) => {
@@ -694,6 +715,7 @@ describe('MatSelect', () => {
694
715
expect ( spy ) . toHaveBeenCalledWith ( true ) ;
695
716
696
717
subscription . unsubscribe ( ) ;
718
+ flush ( ) ;
697
719
} ) ) ;
698
720
699
721
it ( 'should be able to focus the select trigger' , fakeAsync ( ( ) => {
@@ -1898,6 +1920,8 @@ describe('MatSelect', () => {
1898
1920
dispatchKeyboardEvent ( select , 'keydown' , DOWN_ARROW ) ;
1899
1921
1900
1922
expect ( fixture . componentInstance . changeListener ) . toHaveBeenCalledTimes ( 1 ) ;
1923
+
1924
+ flush ( ) ;
1901
1925
} ) ) ;
1902
1926
} ) ;
1903
1927
0 commit comments