Skip to content

Commit 8058770

Browse files
addingamanaveenvignesh5
authored andcommitted
Addin testIDPrefix to support testing
1 parent 84c0e6a commit 8058770

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following props are applicable for the component along with **props supporte
3737
| inputCellLength | number | Yes | 1 | Number of character that can be entered inside a single cell. |
3838
| containerStyle | object | Yes | {} | style for overall container. |
3939
| textInputStyle | object | Yes | {} | style for text input. |
40+
| testIDPrefix | string | Yes | 'otp_input_' | testID prefix, the result will be `otp_input_0` until inputCount |
4041

4142
#### Helper Functions
4243

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class OTPTextView extends Component {
157157
containerStyle,
158158
textInputStyle,
159159
keyboardType,
160+
testIDPrefix,
160161
...textInputProps
161162
} = this.props;
162163

@@ -192,6 +193,7 @@ class OTPTextView extends Component {
192193
multiline={false}
193194
onKeyPress={(e) => this.onKeyPress(e, i)}
194195
{...textInputProps}
196+
testID={`${testIDPrefix}${i}`}
195197
/>
196198
);
197199
}
@@ -211,6 +213,7 @@ OTPTextView.propTypes = {
211213
handleTextChange: PropTypes.func,
212214
inputType: PropTypes.string,
213215
keyboardType: PropTypes.string,
216+
testIDPrefix: PropTypes.string,
214217
};
215218

216219
OTPTextView.defaultProps = {
@@ -222,7 +225,8 @@ OTPTextView.defaultProps = {
222225
containerStyle: {},
223226
textInputStyle: {},
224227
handleTextChange: () => {},
225-
keyboardType: "numeric",
228+
testIDPrefix: "otp_input_",
229+
226230
};
227231

228232
export default OTPTextView;

yarn.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"js-tokens@^3.0.0 || ^4.0.0":
6+
version "4.0.0"
7+
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
8+
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
9+
10+
loose-envify@^1.4.0:
11+
version "1.4.0"
12+
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
13+
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
14+
dependencies:
15+
js-tokens "^3.0.0 || ^4.0.0"
16+
17+
object-assign@^4.1.1:
18+
version "4.1.1"
19+
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
20+
integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==
21+
22+
prop-types@^15.6.2:
23+
version "15.8.1"
24+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
25+
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
26+
dependencies:
27+
loose-envify "^1.4.0"
28+
object-assign "^4.1.1"
29+
react-is "^16.13.1"
30+
31+
react-is@^16.13.1:
32+
version "16.13.1"
33+
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
34+
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

0 commit comments

Comments
 (0)