Skip to content

Commit df5c2dc

Browse files
committed
fixup! feat(cdk/testing): add method to wait for async tasks to complete
Change name
1 parent ee7c989 commit df5c2dc

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/cdk/testing/component-harness.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export interface LocatorFactory {
177177
* Waits for all scheduled or running async tasks to complete. This allows harness
178178
* authors to wait for async tasks outside of the Angular zone.
179179
*/
180-
waitForAsyncTasksToComplete(): Promise<void>;
180+
waitForTasksOutsideAngular(): Promise<void>;
181181
}
182182

183183
/**
@@ -295,8 +295,8 @@ export abstract class ComponentHarness {
295295
* Waits for all scheduled or running async tasks to complete. This allows harness
296296
* authors to wait for async tasks outside of the Angular zone.
297297
*/
298-
protected async waitForAsyncTasksToComplete() {
299-
return this.locatorFactory.waitForAsyncTasksToComplete();
298+
protected async waitForTasksOutsideAngular() {
299+
return this.locatorFactory.waitForTasksOutsideAngular();
300300
}
301301
}
302302

src/cdk/testing/harness-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFac
131131
abstract forceStabilize(): Promise<void>;
132132

133133
// Part of LocatorFactory interface, subclasses will implement.
134-
abstract waitForAsyncTasksToComplete(): Promise<void>;
134+
abstract waitForTasksOutsideAngular(): Promise<void>;
135135

136136
/** Gets the root element for the document. */
137137
protected abstract getDocumentRoot(): E;

src/cdk/testing/protractor/protractor-harness-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class ProtractorHarnessEnvironment extends HarnessEnvironment<ElementFind
2525

2626
async forceStabilize(): Promise<void> {}
2727

28-
async waitForAsyncTasksToComplete(): Promise<void> {
28+
async waitForTasksOutsideAngular(): Promise<void> {
2929
// TODO: figure out how we can do this for the protractor environment.
3030
// https://github.com/angular/components/issues/17412
3131
}

src/cdk/testing/testbed/testbed-harness-environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class TestbedHarnessEnvironment extends HarnessEnvironment<Element> {
6464
await this._fixture.whenStable();
6565
}
6666

67-
async waitForAsyncTasksToComplete(): Promise<void> {
67+
async waitForTasksOutsideAngular(): Promise<void> {
6868
// If we run in the fake async zone, we run "flush" to run any scheduled tasks. This
6969
// ensures that the harnesses behave inside of the FakeAsyncTestZone similar to the
7070
// "AsyncTestZone" and the root zone (i.e. neither fakeAsync or async). Note that we

src/cdk/testing/tests/harnesses/main-component-harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class MainComponentHarness extends ComponentHarness {
104104
await (await this.taskStateTestTrigger()).click();
105105
// Wait for async tasks to complete since the click caused a
106106
// timeout to be scheduled outside of the NgZone.
107-
await this.waitForAsyncTasksToComplete();
107+
await this.waitForTasksOutsideAngular();
108108
return (await this.taskStateTestResult()).text();
109109
}
110110
}

src/cdk/testing/tests/testbed.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ describe('TestbedHarnessEnvironment', () => {
253253
expect(subcomps.length).toBe(2);
254254
});
255255

256-
it('should respect tasks outside of NgZone when stabilizing within native async/await',
256+
it('should be able to wait for tasks outside of Angular within native async/await',
257257
async () => {
258258
expect(await harness.getTaskStateResult()).toBe('result');
259259
});
260260

261-
it('should respect tasks outside of NgZone when stabilizing within async test zone',
261+
it('should be able to wait for tasks outside of Angular within async test zone',
262262
async (() => {
263263
harness.getTaskStateResult().then(res => expect(res).toBe('result'));
264264
}));
265265

266-
it('should respect tasks outside of NgZone when stabilizing within fakeAsync test zone',
266+
it('should be able to wait for tasks outside of Angular within fakeAsync test zone',
267267
fakeAsync(async () => {
268268
expect(await harness.getTaskStateResult()).toBe('result');
269269
}));

0 commit comments

Comments
 (0)