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:
Gabriel Reis 2017-01-09 02:37:56 -08:00 committed by Facebook Github Bot
parent 55ce19d84e
commit 5fdd6b33fa
1 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class Button extends React.Component {
color?: ?string,
accessibilityLabel?: ?string,
disabled?: ?boolean,
testID?: ?string,
};
static propTypes = {
@ -78,6 +79,10 @@ class Button extends React.Component {
* Handler to be called when the user taps the button
*/
onPress: React.PropTypes.func.isRequired,
/**
* Used to locate this view in end-to-end tests.
*/
testID: React.PropTypes.string,
};
render() {
@ -87,6 +92,7 @@ class Button extends React.Component {
onPress,
title,
disabled,
testID,
} = this.props;
const buttonStyles = [styles.button];
const textStyles = [styles.text];
@ -110,6 +116,7 @@ class Button extends React.Component {
accessibilityComponentType="button"
accessibilityLabel={accessibilityLabel}
accessibilityTraits={['button']}
testID={testID}
disabled={disabled}
onPress={onPress}>
<View style={buttonStyles}>