Skip to content

Commit 29468fa

Browse files
committed
fix(cdk/testing): fix change detection timing in testbed (#20465)
1 parent ecde050 commit 29468fa

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/cdk/testing/testbed/unit-test-element.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@ export class UnitTestElement implements TestElement {
6464
constructor(readonly element: Element, private _stabilize: () => Promise<void>) {}
6565

6666
async blur(): Promise<void> {
67-
await this._stabilize();
6867
triggerBlur(this.element as HTMLElement);
6968
await this._stabilize();
7069
}
7170

7271
async clear(): Promise<void> {
73-
await this._stabilize();
7472
if (!isTextInput(this.element)) {
7573
throw Error('Attempting to clear an invalid element');
7674
}
@@ -93,12 +91,10 @@ export class UnitTestElement implements TestElement {
9391
this._dispatchPointerEventIfSupported('pointerup', clientX, clientY);
9492
dispatchMouseEvent(this.element, 'mouseup', clientX, clientY);
9593
dispatchMouseEvent(this.element, 'click', clientX, clientY);
96-
9794
await this._stabilize();
9895
}
9996

10097
async focus(): Promise<void> {
101-
await this._stabilize();
10298
triggerFocus(this.element as HTMLElement);
10399
await this._stabilize();
104100
}
@@ -111,14 +107,12 @@ export class UnitTestElement implements TestElement {
111107
}
112108

113109
async hover(): Promise<void> {
114-
await this._stabilize();
115110
this._dispatchPointerEventIfSupported('pointerenter');
116111
dispatchMouseEvent(this.element, 'mouseenter');
117112
await this._stabilize();
118113
}
119114

120115
async mouseAway(): Promise<void> {
121-
await this._stabilize();
122116
this._dispatchPointerEventIfSupported('pointerleave');
123117
dispatchMouseEvent(this.element, 'mouseleave');
124118
await this._stabilize();
@@ -127,7 +121,6 @@ export class UnitTestElement implements TestElement {
127121
async sendKeys(...keys: (string | TestKey)[]): Promise<void>;
128122
async sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
129123
async sendKeys(...modifiersAndKeys: any[]): Promise<void> {
130-
await this._stabilize();
131124
const args = modifiersAndKeys.map(k => typeof k === 'number' ? keyMap[k as TestKey] : k);
132125
typeInElement(this.element as HTMLElement, ...args);
133126
await this._stabilize();
@@ -162,8 +155,8 @@ export class UnitTestElement implements TestElement {
162155
}
163156

164157
async setInputValue(value: string): Promise<void> {
165-
await this._stabilize();
166158
(this.element as any).value = value;
159+
await this._stabilize();
167160
}
168161

169162
async matchesSelector(selector: string): Promise<boolean> {

0 commit comments

Comments
 (0)