Skip to content

Commit 4563021

Browse files
committed
test: use flushMicrotasks for Promise-based async timing
1 parent 39e219b commit 4563021

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/material/timepicker/testing/timepicker-harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class MatTimepickerHarness extends ComponentHarness {
6060
}
6161
await options[0].click();
6262
// Wait for the timepicker to close after selection
63-
await this.waitForTasksOutsideAngular();
63+
await this.forceStabilize();
6464
}
6565

6666
/** Gets the selector that can be used to find the timepicker's panel. */

src/material/timepicker/timepicker.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import {Component, Injector, Provider, signal, ViewChild, ViewEncapsulation} from '@angular/core';
2-
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
2+
import {
3+
ComponentFixture,
4+
fakeAsync,
5+
flush,
6+
TestBed,
7+
tick,
8+
flushMicrotasks,
9+
} from '@angular/core/testing';
310
import {DateAdapter, MATERIAL_ANIMATIONS, provideNativeDateAdapter} from '../core';
411
import {
512
clearElement,
@@ -161,7 +168,7 @@ describe('MatTimepicker', () => {
161168
fixture.detectChanges();
162169
getOptions()[3].click(); // Select 1:30 AM
163170
fixture.detectChanges();
164-
tick(); // Wait for setTimeout(0) to complete
171+
flushMicrotasks(); // Wait for Promise.resolve().then() to complete
165172
flush();
166173

167174
expect(formControlValue).toBeTruthy();

0 commit comments

Comments
 (0)