Skip to content

Commit 7815948

Browse files
authored
test: switch all async usages to waitForAsync (#20448)
In the latest version of Angular the `async` testing function was renamed to `waitForAsync`. These changes fix up all the places where we were using it.
1 parent 4f1238f commit 7815948

File tree

105 files changed

+365
-316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+365
-316
lines changed

src/cdk-experimental/combobox/combobox.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Optional,
1010
ViewChild
1111
} from '@angular/core';
12-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
12+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
1313
import {By} from '@angular/platform-browser';
1414
import {CdkComboboxModule} from './combobox-module';
1515
import {CdkCombobox} from './combobox';
@@ -35,7 +35,7 @@ describe('Combobox', () => {
3535
let applyButton: DebugElement;
3636
let applyButtonElement: HTMLElement;
3737

38-
beforeEach(async(() => {
38+
beforeEach(waitForAsync(() => {
3939
TestBed.configureTestingModule({
4040
imports: [CdkComboboxModule],
4141
declarations: [ComboboxToggle, FakeDialogContent],
@@ -200,7 +200,7 @@ describe('Combobox', () => {
200200
let combobox: DebugElement;
201201
let comboboxInstance: CdkCombobox<unknown>;
202202

203-
beforeEach(async(() => {
203+
beforeEach(waitForAsync(() => {
204204
TestBed.configureTestingModule({
205205
imports: [CdkComboboxModule],
206206
declarations: [ComboboxToggle, FakeDialogContent],
@@ -271,7 +271,7 @@ describe('Combobox', () => {
271271
let comboboxInstance: CdkCombobox<unknown>;
272272
let comboboxElement: HTMLElement;
273273

274-
beforeEach(async(() => {
274+
beforeEach(waitForAsync(() => {
275275
TestBed.configureTestingModule({
276276
imports: [CdkComboboxModule],
277277
declarations: [ComboboxToggle, FakeDialogContent],

src/cdk-experimental/listbox/listbox.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
ComponentFixture,
3-
async,
3+
waitForAsync,
44
TestBed, tick, fakeAsync,
55
} from '@angular/core/testing';
66
import {Component, DebugElement, ViewChild} from '@angular/core';
@@ -34,14 +34,14 @@ describe('CdkOption and CdkListbox', () => {
3434
let optionInstances: CdkOption[];
3535
let optionElements: HTMLElement[];
3636

37-
beforeEach(async(() => {
37+
beforeEach(waitForAsync(() => {
3838
TestBed.configureTestingModule({
3939
imports: [CdkListboxModule],
4040
declarations: [ListboxWithOptions],
4141
}).compileComponents();
4242
}));
4343

44-
beforeEach(async(() => {
44+
beforeEach(waitForAsync(() => {
4545
fixture = TestBed.createComponent(ListboxWithOptions);
4646
fixture.detectChanges();
4747

@@ -369,14 +369,14 @@ describe('CdkOption and CdkListbox', () => {
369369
let optionInstances: CdkOption[];
370370
let optionElements: HTMLElement[];
371371

372-
beforeEach(async(() => {
372+
beforeEach(waitForAsync(() => {
373373
TestBed.configureTestingModule({
374374
imports: [CdkListboxModule],
375375
declarations: [ListboxMultiselect],
376376
}).compileComponents();
377377
}));
378378

379-
beforeEach(async(() => {
379+
beforeEach(waitForAsync(() => {
380380
fixture = TestBed.createComponent(ListboxMultiselect);
381381
fixture.detectChanges();
382382

@@ -512,14 +512,14 @@ describe('CdkOption and CdkListbox', () => {
512512
let optionInstances: CdkOption[];
513513
let optionElements: HTMLElement[];
514514

515-
beforeEach(async(() => {
515+
beforeEach(waitForAsync(() => {
516516
TestBed.configureTestingModule({
517517
imports: [CdkListboxModule],
518518
declarations: [ListboxActiveDescendant],
519519
}).compileComponents();
520520
}));
521521

522-
beforeEach(async(() => {
522+
beforeEach(waitForAsync(() => {
523523
fixture = TestBed.createComponent(ListboxActiveDescendant);
524524
fixture.detectChanges();
525525

@@ -597,7 +597,7 @@ describe('CdkOption and CdkListbox', () => {
597597
let optionInstances: CdkOption[];
598598
let optionElements: HTMLElement[];
599599

600-
beforeEach(async(() => {
600+
beforeEach(waitForAsync(() => {
601601
TestBed.configureTestingModule({
602602
imports: [CdkListboxModule, FormsModule, ReactiveFormsModule],
603603
declarations: [ListboxControlValueAccessor],
@@ -786,7 +786,7 @@ describe('CdkOption and CdkListbox', () => {
786786
let optionInstances: CdkOption[];
787787
let optionElements: HTMLElement[];
788788

789-
beforeEach(async(() => {
789+
beforeEach(waitForAsync(() => {
790790
TestBed.configureTestingModule({
791791
imports: [CdkListboxModule, CdkComboboxModule],
792792
declarations: [ListboxInsideCombobox],

src/cdk-experimental/menu/context-menu.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, ViewChild, ElementRef, Type, ViewChildren, QueryList} from '@angular/core';
22
import {CdkMenuModule} from './menu-module';
3-
import {TestBed, async, ComponentFixture} from '@angular/core/testing';
3+
import {TestBed, waitForAsync, ComponentFixture} from '@angular/core/testing';
44
import {CdkMenu} from './menu';
55
import {CdkContextMenuTrigger} from './context-menu';
66
import {dispatchMouseEvent} from '@angular/cdk/testing/private';
@@ -13,7 +13,7 @@ describe('CdkContextMenuTrigger', () => {
1313
describe('with simple context menu trigger', () => {
1414
let fixture: ComponentFixture<SimpleContextMenu>;
1515

16-
beforeEach(async(() => {
16+
beforeEach(waitForAsync(() => {
1717
TestBed.configureTestingModule({
1818
imports: [CdkMenuModule],
1919
declarations: [SimpleContextMenu],
@@ -108,7 +108,7 @@ describe('CdkContextMenuTrigger', () => {
108108
describe('nested context menu triggers', () => {
109109
let fixture: ComponentFixture<NestedContextMenu>;
110110

111-
beforeEach(async(() => {
111+
beforeEach(waitForAsync(() => {
112112
TestBed.configureTestingModule({
113113
imports: [CdkMenuModule],
114114
declarations: [NestedContextMenu],
@@ -222,7 +222,7 @@ describe('CdkContextMenuTrigger', () => {
222222
let fixture: ComponentFixture<ContextMenuWithSubmenu>;
223223
let instance: ContextMenuWithSubmenu;
224224

225-
beforeEach(async(() => {
225+
beforeEach(waitForAsync(() => {
226226
TestBed.configureTestingModule({
227227
imports: [CdkMenuModule],
228228
declarations: [ContextMenuWithSubmenu],
@@ -253,7 +253,7 @@ describe('CdkContextMenuTrigger', () => {
253253
let nativeMenuBar: HTMLElement;
254254
let nativeMenuBarTrigger: HTMLElement;
255255

256-
beforeEach(async(() => {
256+
beforeEach(waitForAsync(() => {
257257
TestBed.configureTestingModule({
258258
imports: [CdkMenuModule],
259259
declarations: [ContextMenuWithMenuBarAndInlineMenu],

src/cdk-experimental/menu/item-pointer-entries.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, QueryList, ElementRef, ViewChildren, AfterViewInit} from '@angular/core';
2-
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
2+
import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing';
33
import {createMouseEvent, dispatchEvent} from '@angular/cdk/testing/private';
44
import {Observable} from 'rxjs';
55
import {FocusableElement, getItemPointerEntries} from './item-pointer-entries';
@@ -15,7 +15,7 @@ describe('FocusMouseManger', () => {
1515
mockElements = fixture.componentInstance._allItems.toArray();
1616
}
1717

18-
beforeEach(async(() => {
18+
beforeEach(waitForAsync(() => {
1919
TestBed.configureTestingModule({
2020
declarations: [MultiElementWithConditionalComponent, MockWrapper],
2121
}).compileComponents();

src/cdk-experimental/menu/menu-bar.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ComponentFixture, TestBed, async, fakeAsync, tick} from '@angular/core/testing';
1+
import {ComponentFixture, TestBed, waitForAsync, fakeAsync, tick} from '@angular/core/testing';
22
import {
33
Component,
44
ViewChild,
@@ -43,7 +43,7 @@ describe('MenuBar', () => {
4343
let fixture: ComponentFixture<MenuBarRadioGroup>;
4444
let menuItems: CdkMenuItemRadio[];
4545

46-
beforeEach(async(() => {
46+
beforeEach(waitForAsync(() => {
4747
TestBed.configureTestingModule({
4848
imports: [CdkMenuModule],
4949
declarations: [MenuBarRadioGroup],
@@ -72,7 +72,7 @@ describe('MenuBar', () => {
7272
let fixture: ComponentFixture<MenuBarRadioGroup>;
7373
let menuItems: CdkMenuItemRadio[];
7474

75-
beforeEach(async(() => {
75+
beforeEach(waitForAsync(() => {
7676
TestBed.configureTestingModule({
7777
imports: [CdkMenuModule],
7878
declarations: [MenuBarRadioGroup],
@@ -137,7 +137,7 @@ describe('MenuBar', () => {
137137
detectChanges();
138138
}
139139

140-
beforeEach(async(() => {
140+
beforeEach(waitForAsync(() => {
141141
TestBed.configureTestingModule({
142142
imports: [CdkMenuModule],
143143
declarations: [MultiMenuWithSubmenu],
@@ -562,7 +562,7 @@ describe('MenuBar', () => {
562562
detectChanges();
563563
}
564564

565-
beforeEach(async(() => {
565+
beforeEach(waitForAsync(() => {
566566
TestBed.configureTestingModule({
567567
imports: [CdkMenuModule],
568568
declarations: [MultiMenuWithSubmenu],
@@ -690,7 +690,7 @@ describe('MenuBar', () => {
690690
detectChanges();
691691
}
692692

693-
beforeEach(async(() => {
693+
beforeEach(waitForAsync(() => {
694694
TestBed.configureTestingModule({
695695
imports: [CdkMenuModule],
696696
declarations: [MenuWithCheckboxes],
@@ -757,7 +757,7 @@ describe('MenuBar', () => {
757757
detectChanges();
758758
}
759759

760-
beforeEach(async(() => {
760+
beforeEach(waitForAsync(() => {
761761
TestBed.configureTestingModule({
762762
imports: [CdkMenuModule],
763763
declarations: [MenuWithRadioButtons],
@@ -813,7 +813,7 @@ describe('MenuBar', () => {
813813
grabElementsForTesting();
814814
}
815815

816-
beforeEach(async(() => {
816+
beforeEach(waitForAsync(() => {
817817
TestBed.configureTestingModule({
818818
imports: [CdkMenuModule],
819819
declarations: [MenuBarWithMenusAndInlineMenu],
@@ -933,7 +933,7 @@ describe('MenuBar', () => {
933933
detectChanges();
934934
}
935935

936-
beforeEach(async(() => {
936+
beforeEach(waitForAsync(() => {
937937
TestBed.configureTestingModule({
938938
imports: [CdkMenuModule],
939939
declarations: [MultiMenuWithSubmenu],

src/cdk-experimental/menu/menu-group.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewChild} from '@angular/core';
2-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {CdkMenuModule} from './menu-module';
55
import {CdkMenuGroup} from './menu-group';
@@ -14,7 +14,7 @@ describe('MenuGroup', () => {
1414
let fixture: ComponentFixture<CheckboxMenu>;
1515
let menuItems: CdkMenuItemCheckbox[];
1616

17-
beforeEach(async(() => {
17+
beforeEach(waitForAsync(() => {
1818
TestBed.configureTestingModule({
1919
imports: [CdkMenuModule],
2020
declarations: [CheckboxMenu],
@@ -43,7 +43,7 @@ describe('MenuGroup', () => {
4343
let fixture: ComponentFixture<MenuWithMultipleRadioGroups>;
4444
let menuItems: CdkMenuItemRadio[];
4545

46-
beforeEach(async(() => {
46+
beforeEach(waitForAsync(() => {
4747
TestBed.configureTestingModule({
4848
imports: [CdkMenuModule],
4949
declarations: [MenuWithMultipleRadioGroups],
@@ -89,7 +89,7 @@ describe('MenuGroup', () => {
8989
let fixture: ComponentFixture<MenuWithMenuItemsAndRadioGroups>;
9090
let menuItems: CdkMenuItemRadio[];
9191

92-
beforeEach(async(() => {
92+
beforeEach(waitForAsync(() => {
9393
TestBed.configureTestingModule({
9494
imports: [CdkMenuModule],
9595
declarations: [MenuWithMenuItemsAndRadioGroups],

src/cdk-experimental/menu/menu-item-checkbox.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {CdkMenuModule} from './menu-module';
55
import {CdkMenuItemCheckbox} from './menu-item-checkbox';
@@ -11,7 +11,7 @@ describe('MenuItemCheckbox', () => {
1111
let checkbox: CdkMenuItemCheckbox;
1212
let checkboxElement: HTMLButtonElement;
1313

14-
beforeEach(async(() => {
14+
beforeEach(waitForAsync(() => {
1515
TestBed.configureTestingModule({
1616
imports: [CdkMenuModule],
1717
declarations: [SingleCheckboxButton],

src/cdk-experimental/menu/menu-item-radio.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component} from '@angular/core';
2-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
55
import {CdkMenuModule} from './menu-module';
@@ -13,7 +13,7 @@ describe('MenuItemRadio', () => {
1313
let radioElement: HTMLButtonElement;
1414
let selectionDispatcher: UniqueSelectionDispatcher;
1515

16-
beforeEach(async(() => {
16+
beforeEach(waitForAsync(() => {
1717
selectionDispatcher = new UniqueSelectionDispatcher();
1818
TestBed.configureTestingModule({
1919
imports: [CdkMenuModule],

src/cdk-experimental/menu/menu-item-trigger.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, ViewChildren, QueryList, ElementRef, ViewChild, Type} from '@angular/core';
2-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {dispatchKeyboardEvent} from '@angular/cdk/testing/private';
55
import {TAB, SPACE} from '@angular/cdk/keycodes';
@@ -15,7 +15,7 @@ describe('MenuItemTrigger', () => {
1515
let menuItem: CdkMenuItem;
1616
let menuItemElement: HTMLButtonElement;
1717

18-
beforeEach(async(() => {
18+
beforeEach(waitForAsync(() => {
1919
TestBed.configureTestingModule({
2020
imports: [CdkMenuModule],
2121
declarations: [TriggerForEmptyMenu],
@@ -82,7 +82,7 @@ describe('MenuItemTrigger', () => {
8282

8383
const setDocumentDirection = (dir: 'ltr' | 'rtl') => (document.dir = dir);
8484

85-
beforeEach(async(() => {
85+
beforeEach(waitForAsync(() => {
8686
TestBed.configureTestingModule({
8787
imports: [CdkMenuModule],
8888
declarations: [MenuBarWithNestedSubMenus],
@@ -351,7 +351,7 @@ describe('MenuItemTrigger', () => {
351351
grabElementsForTesting();
352352
};
353353

354-
beforeEach(async(() => {
354+
beforeEach(waitForAsync(() => {
355355
TestBed.configureTestingModule({
356356
imports: [CdkMenuModule],
357357
declarations: [StandaloneTriggerWithInlineMenu],

src/cdk-experimental/menu/menu-item.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, Type} from '@angular/core';
2-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
2+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {CdkMenuModule} from './menu-module';
55
import {CdkMenuItem} from './menu-item';
@@ -12,7 +12,7 @@ describe('MenuItem', () => {
1212
let menuItem: CdkMenuItem;
1313
let nativeButton: HTMLButtonElement;
1414

15-
beforeEach(async(() => {
15+
beforeEach(waitForAsync(() => {
1616
TestBed.configureTestingModule({
1717
imports: [CdkMenuModule],
1818
declarations: [SingleMenuItem],

src/cdk-experimental/menu/menu-stack.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {QueryList, ViewChild, ViewChildren, Component} from '@angular/core';
22
import {CdkMenu} from './menu';
33
import {CdkMenuBar} from './menu-bar';
4-
import {ComponentFixture, TestBed, async} from '@angular/core/testing';
4+
import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing';
55
import {CdkMenuItemTrigger} from './menu-item-trigger';
66
import {MenuStack} from './menu-stack';
77
import {CdkMenuModule} from './menu-module';
@@ -20,7 +20,7 @@ describe('MenuStack', () => {
2020
menuStack = fixture.componentInstance.menuBar._menuStack;
2121
}
2222

23-
beforeEach(async(() => {
23+
beforeEach(waitForAsync(() => {
2424
TestBed.configureTestingModule({
2525
imports: [CdkMenuModule],
2626
declarations: [MultiMenuWithSubmenu],

0 commit comments

Comments
 (0)