Add testID prop to Button component
Summary: This PR adds the `testID` prop to the `Button` component in order to allow end-to-end tests. Closes https://github.com/facebook/react-native/pull/11526 Differential Revision: D4392137 Pulled By: ericvicenti fbshipit-source-id: d3f864aacee319e520af226cd063edef452f6fc8
This commit is contained in:
parent
55ce19d84e
commit
5fdd6b33fa
|
@ -55,6 +55,7 @@ class Button extends React.Component {
|
||||||
color?: ?string,
|
color?: ?string,
|
||||||
accessibilityLabel?: ?string,
|
accessibilityLabel?: ?string,
|
||||||
disabled?: ?boolean,
|
disabled?: ?boolean,
|
||||||
|
testID?: ?string,
|
||||||
};
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -78,6 +79,10 @@ class Button extends React.Component {
|
||||||
* Handler to be called when the user taps the button
|
* Handler to be called when the user taps the button
|
||||||
*/
|
*/
|
||||||
onPress: React.PropTypes.func.isRequired,
|
onPress: React.PropTypes.func.isRequired,
|
||||||
|
/**
|
||||||
|
* Used to locate this view in end-to-end tests.
|
||||||
|
*/
|
||||||
|
testID: React.PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -87,6 +92,7 @@ class Button extends React.Component {
|
||||||
onPress,
|
onPress,
|
||||||
title,
|
title,
|
||||||
disabled,
|
disabled,
|
||||||
|
testID,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const buttonStyles = [styles.button];
|
const buttonStyles = [styles.button];
|
||||||
const textStyles = [styles.text];
|
const textStyles = [styles.text];
|
||||||
|
@ -110,6 +116,7 @@ class Button extends React.Component {
|
||||||
accessibilityComponentType="button"
|
accessibilityComponentType="button"
|
||||||
accessibilityLabel={accessibilityLabel}
|
accessibilityLabel={accessibilityLabel}
|
||||||
accessibilityTraits={['button']}
|
accessibilityTraits={['button']}
|
||||||
|
testID={testID}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onPress={onPress}>
|
onPress={onPress}>
|
||||||
<View style={buttonStyles}>
|
<View style={buttonStyles}>
|
||||||
|
|
Loading…
Reference in New Issue