Skip to content

Commit 317ee99

Browse files
committed
refactor: renaming
1 parent 687d07a commit 317ee99

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

src/fire-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,6 @@ function setNativeStateIfNeeded(element: ReactTestInstance, eventName: string, v
154154
isHostTextInput(element) &&
155155
isTextInputEditable(element)
156156
) {
157-
nativeState?.elementValues.set(element, value);
157+
nativeState?.valueForElement.set(element, value);
158158
}
159159
}

src/helpers/text-input.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function getTextInputValue(element: ReactTestInstance) {
1717

1818
return (
1919
element.props.value ??
20-
nativeState?.elementValues.get(element) ??
20+
nativeState?.valueForElement.get(element) ??
2121
element.props.defaultValue ??
2222
''
2323
);

src/native-state.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import { Point } from './types';
77
* Values from `value` props (managed controls) should take precedence over these values.
88
*/
99
export type NativeState = {
10-
elementValues: WeakMap<ReactTestInstance, string>;
11-
scrollPositions: WeakMap<ReactTestInstance, Point>;
10+
valueForElement: WeakMap<ReactTestInstance, string>;
11+
contentOffsetForElement: WeakMap<ReactTestInstance, Point>;
1212
};
1313

1414
export let nativeState: NativeState | null = null;
1515

1616
export function initNativeState(): void {
1717
nativeState = {
18-
elementValues: new WeakMap(),
19-
scrollPositions: new WeakMap(),
18+
valueForElement: new WeakMap(),
19+
contentOffsetForElement: new WeakMap(),
2020
};
2121
}
2222

src/user-event/paste.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function paste(
3333
dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(rangeToClear));
3434

3535
// 3. Paste the text
36-
nativeState?.elementValues.set(element, text);
36+
nativeState?.valueForElement.set(element, text);
3737
dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));
3838
dispatchEvent(element, 'changeText', text);
3939

src/user-event/scroll/scroll-to.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export async function scrollTo(
5656
options.contentSize?.height ?? 0,
5757
);
5858

59-
const initialPosition = nativeState?.scrollPositions.get(element) ?? { x: 0, y: 0 };
59+
const initialPosition = nativeState?.contentOffsetForElement.get(element) ?? { x: 0, y: 0 };
6060
const dragSteps = createScrollSteps(
6161
{ y: options.y, x: options.x },
6262
initialPosition,
@@ -73,7 +73,7 @@ export async function scrollTo(
7373
await emitMomentumScrollEvents(this.config, element, momentumSteps, options);
7474

7575
const finalPosition = momentumSteps.at(-1) ?? dragSteps.at(-1) ?? initialPosition;
76-
nativeState?.scrollPositions.set(element, finalPosition);
76+
nativeState?.contentOffsetForElement.set(element, finalPosition);
7777
}
7878

7979
async function emitDragScrollEvents(

src/user-event/type/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function emitTypingEvents(
9595
return;
9696
}
9797

98-
nativeState?.elementValues.set(element, text);
98+
nativeState?.valueForElement.set(element, text);
9999
dispatchEvent(element, 'change', EventBuilder.TextInput.change(text));
100100
dispatchEvent(element, 'changeText', text);
101101

0 commit comments

Comments
 (0)