@@ -102,11 +102,11 @@ describe('MatAutocomplete', () => {
102102 let fixture : ComponentFixture < SimpleAutocomplete > ;
103103 let input : HTMLInputElement ;
104104
105- beforeEach ( ( ) => {
105+ beforeEach ( fakeAsync ( ( ) => {
106106 fixture = createComponent ( SimpleAutocomplete ) ;
107107 fixture . detectChanges ( ) ;
108108 input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
109- } ) ;
109+ } ) ) ;
110110
111111 it ( 'should open the panel when the input is focused' , ( ) => {
112112 expect ( fixture . componentInstance . trigger . panelOpen )
@@ -411,7 +411,7 @@ describe('MatAutocomplete', () => {
411411 } ) ) ;
412412 } ) ;
413413
414- it ( 'should have the correct text direction in RTL' , ( ) => {
414+ it ( 'should have the correct text direction in RTL' , fakeAsync ( ( ) => {
415415 const rtlFixture = createComponent ( SimpleAutocomplete , [
416416 { provide : Directionality , useFactory : ( ) => ( { value : 'rtl' } ) } ,
417417 ] ) ;
@@ -423,18 +423,18 @@ describe('MatAutocomplete', () => {
423423 const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) ! ;
424424 expect ( overlayPane . getAttribute ( 'dir' ) ) . toEqual ( 'rtl' ) ;
425425
426- } ) ;
426+ } ) ) ;
427427
428428 describe ( 'forms integration' , ( ) => {
429429 let fixture : ComponentFixture < SimpleAutocomplete > ;
430430 let input : HTMLInputElement ;
431431
432- beforeEach ( ( ) => {
432+ beforeEach ( fakeAsync ( ( ) => {
433433 fixture = createComponent ( SimpleAutocomplete ) ;
434434 fixture . detectChanges ( ) ;
435435
436436 input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
437- } ) ;
437+ } ) ) ;
438438
439439 it ( 'should update control value as user types with input value' , ( ) => {
440440 fixture . componentInstance . trigger . openPanel ( ) ;
@@ -615,22 +615,23 @@ describe('MatAutocomplete', () => {
615615 . toBe ( true , `Expected control to become touched on blur.` ) ;
616616 } ) ;
617617
618- it ( 'should disable the input when used with a value accessor and without `matInput`' , ( ) => {
619- overlayContainer . ngOnDestroy ( ) ;
620- fixture . destroy ( ) ;
621- TestBed . resetTestingModule ( ) ;
618+ it ( 'should disable the input when used with a value accessor and without `matInput`' ,
619+ fakeAsync ( ( ) => {
620+ overlayContainer . ngOnDestroy ( ) ;
621+ fixture . destroy ( ) ;
622+ TestBed . resetTestingModule ( ) ;
622623
623- const plainFixture = createComponent ( PlainAutocompleteInputWithFormControl ) ;
624- plainFixture . detectChanges ( ) ;
625- input = plainFixture . nativeElement . querySelector ( 'input' ) ;
624+ const plainFixture = createComponent ( PlainAutocompleteInputWithFormControl ) ;
625+ plainFixture . detectChanges ( ) ;
626+ input = plainFixture . nativeElement . querySelector ( 'input' ) ;
626627
627- expect ( input . disabled ) . toBe ( false ) ;
628+ expect ( input . disabled ) . toBe ( false ) ;
628629
629- plainFixture . componentInstance . formControl . disable ( ) ;
630- plainFixture . detectChanges ( ) ;
630+ plainFixture . componentInstance . formControl . disable ( ) ;
631+ plainFixture . detectChanges ( ) ;
631632
632- expect ( input . disabled ) . toBe ( true ) ;
633- } ) ;
633+ expect ( input . disabled ) . toBe ( true ) ;
634+ } ) ) ;
634635
635636 } ) ;
636637
@@ -1088,12 +1089,12 @@ describe('MatAutocomplete', () => {
10881089 let fixture : ComponentFixture < SimpleAutocomplete > ;
10891090 let input : HTMLInputElement ;
10901091
1091- beforeEach ( ( ) => {
1092+ beforeEach ( fakeAsync ( ( ) => {
10921093 fixture = createComponent ( SimpleAutocomplete ) ;
10931094 fixture . detectChanges ( ) ;
10941095
10951096 input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
1096- } ) ;
1097+ } ) ) ;
10971098
10981099 it ( 'should set role of input to combobox' , ( ) => {
10991100 expect ( input . getAttribute ( 'role' ) )
@@ -1205,13 +1206,13 @@ describe('MatAutocomplete', () => {
12051206 let input : HTMLInputElement ;
12061207 let inputReference : HTMLInputElement ;
12071208
1208- beforeEach ( ( ) => {
1209+ beforeEach ( fakeAsync ( ( ) => {
12091210 fixture = createComponent ( SimpleAutocomplete ) ;
12101211 fixture . detectChanges ( ) ;
12111212
12121213 input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
12131214 inputReference = fixture . debugElement . query ( By . css ( '.mat-input-flex' ) ) . nativeElement ;
1214- } ) ;
1215+ } ) ) ;
12151216
12161217 it ( 'should use below positioning by default' , fakeAsync ( ( ) => {
12171218 fixture . componentInstance . trigger . openPanel ( ) ;
@@ -1292,10 +1293,10 @@ describe('MatAutocomplete', () => {
12921293 describe ( 'Option selection' , ( ) => {
12931294 let fixture : ComponentFixture < SimpleAutocomplete > ;
12941295
1295- beforeEach ( ( ) => {
1296+ beforeEach ( fakeAsync ( ( ) => {
12961297 fixture = createComponent ( SimpleAutocomplete ) ;
12971298 fixture . detectChanges ( ) ;
1298- } ) ;
1299+ } ) ) ;
12991300
13001301 it ( 'should deselect any other selected option' , fakeAsync ( ( ) => {
13011302 fixture . componentInstance . trigger . openPanel ( ) ;
@@ -1485,10 +1486,10 @@ describe('MatAutocomplete', () => {
14851486 describe ( 'without matInput' , ( ) => {
14861487 let fixture : ComponentFixture < AutocompleteWithNativeInput > ;
14871488
1488- beforeEach ( ( ) => {
1489+ beforeEach ( fakeAsync ( ( ) => {
14891490 fixture = createComponent ( AutocompleteWithNativeInput ) ;
14901491 fixture . detectChanges ( ) ;
1491- } ) ;
1492+ } ) ) ;
14921493
14931494 it ( 'should not throw when clicking outside' , fakeAsync ( ( ) => {
14941495 dispatchFakeEvent ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement , 'focus' ) ;
@@ -1501,27 +1502,28 @@ describe('MatAutocomplete', () => {
15011502
15021503 describe ( 'misc' , ( ) => {
15031504
1504- it ( 'should allow basic use without any forms directives' , ( ) => {
1505+ it ( 'should allow basic use without any forms directives' , fakeAsync ( ( ) => {
15051506 expect ( ( ) => {
15061507 const fixture = createComponent ( AutocompleteWithoutForms ) ;
15071508 fixture . detectChanges ( ) ;
15081509
15091510 const input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
15101511 typeInElement ( 'd' , input ) ;
15111512 fixture . detectChanges ( ) ;
1513+ tick ( ) ;
15121514
15131515 const options =
15141516 overlayContainerElement . querySelectorAll ( 'mat-option' ) as NodeListOf < HTMLElement > ;
15151517 expect ( options . length ) . toBe ( 1 ) ;
15161518 } ) . not . toThrowError ( ) ;
1517- } ) ;
1519+ } ) ) ;
15181520
1519- it ( 'should display an empty input when the value is undefined with ngModel' , ( ) => {
1521+ it ( 'should display an empty input when the value is undefined with ngModel' , fakeAsync ( ( ) => {
15201522 const fixture = createComponent ( AutocompleteWithNgModel ) ;
15211523 fixture . detectChanges ( ) ;
15221524
15231525 expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . value ) . toBe ( '' ) ;
1524- } ) ;
1526+ } ) ) ;
15251527
15261528 it ( 'should display the number when the selected option is the number zero' , fakeAsync ( ( ) => {
15271529 const fixture = createComponent ( AutocompleteWithNumbers ) ;
@@ -1533,7 +1535,7 @@ describe('MatAutocomplete', () => {
15331535 expect ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement . value ) . toBe ( '0' ) ;
15341536 } ) ) ;
15351537
1536- it ( 'should work when input is wrapped in ngIf' , ( ) => {
1538+ it ( 'should work when input is wrapped in ngIf' , fakeAsync ( ( ) => {
15371539 const fixture = createComponent ( NgIfAutocomplete ) ;
15381540 fixture . detectChanges ( ) ;
15391541
@@ -1546,9 +1548,9 @@ describe('MatAutocomplete', () => {
15461548 . toContain ( 'One' , `Expected panel to display when input is focused.` ) ;
15471549 expect ( overlayContainerElement . textContent )
15481550 . toContain ( 'Two' , `Expected panel to display when input is focused.` ) ;
1549- } ) ;
1551+ } ) ) ;
15501552
1551- it ( 'should filter properly with ngIf after setting the active item' , ( ) => {
1553+ it ( 'should filter properly with ngIf after setting the active item' , fakeAsync ( ( ) => {
15521554 const fixture = createComponent ( NgIfAutocomplete ) ;
15531555 fixture . detectChanges ( ) ;
15541556
@@ -1562,18 +1564,19 @@ describe('MatAutocomplete', () => {
15621564 const input = fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement ;
15631565 typeInElement ( 'o' , input ) ;
15641566 fixture . detectChanges ( ) ;
1567+ tick ( ) ;
15651568
15661569 expect ( fixture . componentInstance . matOptions . length ) . toBe ( 2 ) ;
1567- } ) ;
1570+ } ) ) ;
15681571
1569- it ( 'should throw if the user attempts to open the panel too early' , ( ) => {
1572+ it ( 'should throw if the user attempts to open the panel too early' , fakeAsync ( ( ) => {
15701573 const fixture = createComponent ( AutocompleteWithoutPanel ) ;
15711574 fixture . detectChanges ( ) ;
15721575
15731576 expect ( ( ) => {
15741577 fixture . componentInstance . trigger . openPanel ( ) ;
15751578 } ) . toThrow ( getMatAutocompleteMissingPanelError ( ) ) ;
1576- } ) ;
1579+ } ) ) ;
15771580
15781581 it ( 'should not throw on init, even if the panel is not defined' , fakeAsync ( ( ) => {
15791582 expect ( ( ) => {
@@ -1652,7 +1655,7 @@ describe('MatAutocomplete', () => {
16521655
16531656 } ) ;
16541657
1655- it ( 'should have correct width when opened' , ( ) => {
1658+ it ( 'should have correct width when opened' , fakeAsync ( ( ) => {
16561659 const widthFixture = createComponent ( SimpleAutocomplete ) ;
16571660 widthFixture . componentInstance . width = 300 ;
16581661 widthFixture . detectChanges ( ) ;
@@ -1675,9 +1678,9 @@ describe('MatAutocomplete', () => {
16751678
16761679 // Firefox, edge return a decimal value for width, so we need to parse and round it to verify
16771680 expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 500 ) ;
1678- } ) ;
1681+ } ) ) ;
16791682
1680- it ( 'should update the width while the panel is open' , ( ) => {
1683+ it ( 'should update the width while the panel is open' , fakeAsync ( ( ) => {
16811684 const widthFixture = createComponent ( SimpleAutocomplete ) ;
16821685
16831686 widthFixture . componentInstance . width = 300 ;
@@ -1699,7 +1702,7 @@ describe('MatAutocomplete', () => {
16991702 widthFixture . detectChanges ( ) ;
17001703
17011704 expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 500 ) ;
1702- } ) ;
1705+ } ) ) ;
17031706
17041707 it ( 'should show the panel when the options are initialized later within a component with ' +
17051708 'OnPush change detection' , fakeAsync ( ( ) => {
0 commit comments