Skip to content

Commit 3f9d944

Browse files
committed
refactor: fix ts, tweak naming
1 parent 9747614 commit 3f9d944

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/user-event/clear.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,23 @@ export async function clear(this: UserEventInstance, element: ReactTestInstance)
2424
dispatchEvent(element, 'focus', EventBuilder.Common.focus());
2525

2626
// 2. Select all
27-
const previousText = element.props.value ?? element.props.defaultValue ?? '';
27+
const textToClear = element.props.value ?? element.props.defaultValue ?? '';
2828
const selectionRange = {
2929
start: 0,
30-
end: previousText.length,
30+
end: textToClear.length,
3131
};
3232
dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));
3333

3434
// 3. Press backspace with selected text
35-
const finalText = '';
35+
const textAfterClear = '';
3636
await emitTypingEvents(element, {
3737
config: this.config,
3838
key: 'Backspace',
39-
text: finalText,
40-
previousText,
39+
text: textAfterClear,
4140
});
4241

4342
// 4. Exit element
4443
await wait(this.config);
45-
dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(finalText));
46-
44+
dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(textAfterClear));
4745
dispatchEvent(element, 'blur', EventBuilder.Common.blur());
4846
}

0 commit comments

Comments
 (0)