Skip to content

Commit 33d19ac

Browse files
committed
refactor: code review changes
1 parent 7bef046 commit 33d19ac

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/helpers/accessiblity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import { ReactTestInstance } from 'react-test-renderer';
77
import { getConfig } from '../config';
88
import { getHostSiblings } from './component-tree';
9+
import { getHostComponentNames } from './host-component-names';
910

1011
type IsInaccessibleOptions = {
1112
cache?: WeakMap<ReactTestInstance, boolean>;
@@ -99,8 +100,7 @@ export function isAccessibilityElement(
99100
return element.props.accessible;
100101
}
101102

102-
const hostComponentNames = getConfig().hostComponentNames;
103-
103+
const hostComponentNames = getHostComponentNames();
104104
return (
105105
element?.type === hostComponentNames?.text ||
106106
element?.type === hostComponentNames?.textInput ||

src/user-event/type/type.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactTestInstance } from 'react-test-renderer';
2-
import { getConfig } from '../../config';
2+
import { getHostComponentNames } from '../../helpers/host-component-names';
33
import { EventBuilder } from '../event-builder';
44
import { ErrorWithStack } from '../../helpers/errors';
55
import { UserEventInstance } from '../setup';
@@ -23,7 +23,7 @@ export async function type(
2323
text: string,
2424
options?: TypeOptions
2525
): Promise<void> {
26-
if (element.type !== getConfig().hostComponentNames?.textInput) {
26+
if (element.type !== getHostComponentNames().textInput) {
2727
throw new ErrorWithStack(
2828
`type() works only with "TextInput" elements. Passed element has type "${element.type}".`,
2929
type
@@ -32,15 +32,15 @@ export async function type(
3232

3333
const keys = parseKeys(text);
3434

35-
if (options?.skipPress !== true) {
35+
if (!options?.skipPress) {
3636
await wait(this.config);
3737
dispatchOwnHostEvent(element, 'pressIn', EventBuilder.Common.touch());
3838
}
3939

4040
await wait(this.config);
4141
dispatchOwnHostEvent(element, 'focus', EventBuilder.Common.focus());
4242

43-
if (options?.skipPress !== true) {
43+
if (!options?.skipPress) {
4444
dispatchOwnHostEvent(element, 'pressOut', EventBuilder.Common.touch());
4545
}
4646

@@ -55,7 +55,7 @@ export async function type(
5555

5656
const finalText = element.props.value ?? currentText;
5757

58-
if (options?.submitEditing === true) {
58+
if (options?.submitEditing) {
5959
await wait(this.config);
6060
dispatchOwnHostEvent(
6161
element,

src/user-event/utils/dispatch-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function dispatchHostEvent(
2828
}
2929

3030
/**
31-
* Dispatch event functio only to given element. Does not look event handler
31+
* Dispatch event function only to given element. Does not look event handler
3232
* in the ancestors.
3333
*
3434
* @param element element trigger event on

0 commit comments

Comments
 (0)