Skip to content

Commit addf142

Browse files
committed
fix(cdk/testing): fix change detection timing in testbed (#20465)
(cherry picked from commit e01fac4)
1 parent d307e3e commit addf142

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
@@ -57,13 +57,11 @@ export class UnitTestElement implements TestElement {
5757
constructor(readonly element: Element, private _stabilize: () => Promise<void>) {}
5858

5959
async blur(): Promise<void> {
60-
await this._stabilize();
6160
triggerBlur(this.element as HTMLElement);
6261
await this._stabilize();
6362
}
6463

6564
async clear(): Promise<void> {
66-
await this._stabilize();
6765
if (!isTextInput(this.element)) {
6866
throw Error('Attempting to clear an invalid element');
6967
}
@@ -86,12 +84,10 @@ export class UnitTestElement implements TestElement {
8684
this._dispatchPointerEventIfSupported('pointerup', clientX, clientY);
8785
dispatchMouseEvent(this.element, 'mouseup', clientX, clientY);
8886
dispatchMouseEvent(this.element, 'click', clientX, clientY);
89-
9087
await this._stabilize();
9188
}
9289

9390
async focus(): Promise<void> {
94-
await this._stabilize();
9591
triggerFocus(this.element as HTMLElement);
9692
await this._stabilize();
9793
}
@@ -104,14 +100,12 @@ export class UnitTestElement implements TestElement {
104100
}
105101

106102
async hover(): Promise<void> {
107-
await this._stabilize();
108103
this._dispatchPointerEventIfSupported('pointerenter');
109104
dispatchMouseEvent(this.element, 'mouseenter');
110105
await this._stabilize();
111106
}
112107

113108
async mouseAway(): Promise<void> {
114-
await this._stabilize();
115109
this._dispatchPointerEventIfSupported('pointerleave');
116110
dispatchMouseEvent(this.element, 'mouseleave');
117111
await this._stabilize();
@@ -120,7 +114,6 @@ export class UnitTestElement implements TestElement {
120114
async sendKeys(...keys: (string | TestKey)[]): Promise<void>;
121115
async sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
122116
async sendKeys(...modifiersAndKeys: any[]): Promise<void> {
123-
await this._stabilize();
124117
const args = modifiersAndKeys.map(k => typeof k === 'number' ? keyMap[k as TestKey] : k);
125118
typeInElement(this.element as HTMLElement, ...args);
126119
await this._stabilize();
@@ -152,8 +145,8 @@ export class UnitTestElement implements TestElement {
152145
}
153146

154147
async setInputValue(value: string): Promise<void> {
155-
await this._stabilize();
156148
(this.element as any).value = value;
149+
await this._stabilize();
157150
}
158151

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

0 commit comments

Comments
 (0)