@@ -12,6 +12,7 @@ import { isHostTextInput } from './helpers/host-component-names';
12
12
import { isPointerEventEnabled } from './helpers/pointer-events' ;
13
13
import { isTextInputEditable } from './helpers/text-input' ;
14
14
import { StringWithAutocomplete } from './types' ;
15
+ import { nativeState } from './native-state' ;
15
16
16
17
type EventHandler = ( ...args : unknown [ ] ) => unknown ;
17
18
@@ -120,6 +121,8 @@ type EventName = StringWithAutocomplete<
120
121
> ;
121
122
122
123
function fireEvent ( element : ReactTestInstance , eventName : EventName , ...data : unknown [ ] ) {
124
+ setNativeStateIfNeeded ( element , eventName , data [ 0 ] ) ;
125
+
123
126
const handler = findEventHandler ( element , eventName ) ;
124
127
if ( ! handler ) {
125
128
return ;
@@ -143,3 +146,14 @@ fireEvent.scroll = (element: ReactTestInstance, ...data: unknown[]) =>
143
146
fireEvent ( element , 'scroll' , ...data ) ;
144
147
145
148
export default fireEvent ;
149
+
150
+ function setNativeStateIfNeeded ( element : ReactTestInstance , eventName : string , value : unknown ) {
151
+ if (
152
+ eventName === 'changeText' &&
153
+ typeof value === 'string' &&
154
+ isHostTextInput ( element ) &&
155
+ isTextInputEditable ( element )
156
+ ) {
157
+ nativeState ?. elementValues . set ( element , value ) ;
158
+ }
159
+ }
0 commit comments