Skip to content

Commit 83cbc0b

Browse files
authored
Allow test props to be added to elements
Add new config settings (leftElementProps, inputProps, rightElementProps), so we can add test props (e.g. testID, accessibilityLabel, etc) to each of the main elements for end-to-end testing.
1 parent ca67a11 commit 83cbc0b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ class InputSpinner extends Component {
754754
onShowUnderlay={this.onShowUnderlay.bind(this, "left")}
755755
disabled={this._isDisabledButtonLeft()}
756756
style={buttonStyle}
757-
onPress={() => this.decrease()}>
757+
onPress={() => this.decrease()}
758+
{...this.props.leftElementProps}>
758759
{this._renderLeftButtonElement()}
759760
</TouchableHighlight>
760761
);
@@ -788,7 +789,8 @@ class InputSpinner extends Component {
788789
onShowUnderlay={this.onShowUnderlay.bind(this, "right")}
789790
disabled={this._isDisabledButtonRight()}
790791
style={buttonStyle}
791-
onPress={() => this.increase()}>
792+
onPress={() => this.increase()}
793+
{...this.props.rightElementProps}>
792794
{this._renderRightButtonElement()}
793795
</TouchableHighlight>
794796
);
@@ -800,7 +802,7 @@ class InputSpinner extends Component {
800802
*/
801803
render() {
802804
return (
803-
<View style={this._getContainerStyle()}>
805+
<View style={this._getContainerStyle()} {...this.props.containerProps}>
804806
{this._renderLeftButton()}
805807

806808
{this.props.prepend}
@@ -822,6 +824,7 @@ class InputSpinner extends Component {
822824
keyboardType={this._getKeyboardType()}
823825
onChangeText={this.onChange.bind(this)}
824826
onSubmitEditing={this.onSubmit.bind(this)}
827+
{...this.props.inputProps}
825828
/>
826829

827830
{this.props.children}
@@ -891,6 +894,10 @@ InputSpinner.propTypes = {
891894
append: PropTypes.element,
892895
prepend: PropTypes.element,
893896
decimalSeparator: PropTypes.string,
897+
containerProps: PropTypes.object,
898+
leftElementProps: PropTypes.object,
899+
inputProps: PropTypes.object,
900+
rightElementProps: PropTypes.object,
894901
};
895902

896903
InputSpinner.defaultProps = {
@@ -936,6 +943,10 @@ InputSpinner.defaultProps = {
936943
inputStyle: {},
937944
style: {},
938945
decimalSeparator: ".",
946+
containerProps: {},
947+
leftElementProps: {},
948+
inputProps: {},
949+
rightElementProps: {},
939950
};
940951

941952
export default InputSpinner;

0 commit comments

Comments
 (0)