File tree Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Expand file tree Collapse file tree 2 files changed +4
-12
lines changed Original file line number Diff line number Diff line change 1
1
import * as React from 'react' ;
2
2
import { TextInput , TextInputProps , View } from 'react-native' ;
3
- import {
4
- createEventLogger ,
5
- getEventsNames ,
6
- lastEvent ,
7
- lastEventPayload ,
8
- } from '../../../test-utils' ;
3
+ import { createEventLogger , getEventsNames , lastEventPayload } from '../../../test-utils' ;
9
4
import { render , screen } from '../../..' ;
10
5
import { userEvent } from '../..' ;
11
6
Original file line number Diff line number Diff line change @@ -48,11 +48,8 @@ export async function type(
48
48
for ( const key of keys ) {
49
49
const previousText = element . props . value ?? currentText ;
50
50
const proposedText = applyKey ( previousText , key ) ;
51
- let isAccepted = false ;
52
- if ( isTextChangeAllowed ( element , proposedText ) ) {
53
- currentText = proposedText ;
54
- isAccepted = true ;
55
- }
51
+ const isAccepted = isTextChangeAccepted ( element , proposedText ) ;
52
+ currentText = isAccepted ? proposedText : previousText ;
56
53
57
54
await emitTypingEvents ( element , {
58
55
config : this . config ,
@@ -138,7 +135,7 @@ function applyKey(text: string, key: string) {
138
135
return text + key ;
139
136
}
140
137
141
- function isTextChangeAllowed ( element : ReactTestInstance , text : string ) {
138
+ function isTextChangeAccepted ( element : ReactTestInstance , text : string ) {
142
139
const maxLength = element . props . maxLength ;
143
140
return maxLength === undefined || text . length <= maxLength ;
144
141
}
You can’t perform that action at this time.
0 commit comments