From b1619e8dc3ece0499beb044e29b7fbef345d7799 Mon Sep 17 00:00:00 2001 From: Marius Reimer Date: Tue, 13 Nov 2018 15:15:32 +0100 Subject: [PATCH] (feat) added testID property --- README.md | 1 + StarButton.js | 4 ++++ StarRating.js | 7 ++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a05d64c..3245801 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ please refer to [react-native-vector-icons installation guide](https://github.co |Prop|Type|Description|Required|Default| |---|---|---|---|---| +|**`testID`**|`string`|A unique identifier for this element to be used in UI Automation testing scripts. Each star can be accessed depending on its index. For example: `star-0`.|`No`|`undefined`| |**`activeOpacity`**|`number`|Number between 0 a 1 to determine the opacity of the button.|`No`|`0.2`| |**`animation`**|`string`|Add an animation to the stars when upon selection. Refer to [react-native-animatable](https://github.com/oblador/react-native-animatable) for the different animation types.|`No`|`undefined`| |**`buttonStyle`**|`ViewPropTypes.style`|Style of the button containing the star.|`No`|*`{}`*| diff --git a/StarButton.js b/StarButton.js index b6db613..7e98a6b 100644 --- a/StarButton.js +++ b/StarButton.js @@ -33,6 +33,7 @@ const iconSets = { }; const propTypes = { + testID: ViewPropTypes.testID, buttonStyle: ViewPropTypes.style, disabled: PropTypes.bool.isRequired, halfStarEnabled: PropTypes.bool.isRequired, @@ -97,6 +98,7 @@ class StarButton extends Component { renderIcon() { const { + testID, reversed, starColor, starIconName, @@ -117,6 +119,7 @@ class StarButton extends Component { if (typeof starIconName === 'string') { iconElement = ( diff --git a/StarRating.js b/StarRating.js index 7aecc95..afe7d88 100644 --- a/StarRating.js +++ b/StarRating.js @@ -21,6 +21,7 @@ const ANIMATION_TYPES = [ ]; const propTypes = { + testID: PropTypes.string, activeOpacity: PropTypes.number, animation: PropTypes.oneOf(ANIMATION_TYPES), buttonStyle: ViewPropTypes.style, @@ -57,6 +58,7 @@ const propTypes = { }; const defaultProps = { + testID: undefined, activeOpacity: 0.2, animation: undefined, buttonStyle: {}, @@ -95,6 +97,7 @@ class StarRating extends Component { render() { const { + testID, activeOpacity, animation, buttonStyle, @@ -145,9 +148,11 @@ class StarRating extends Component { const starButtonElement = ( { this.starRef.push(node); }} > + {starButtons} );