diff --git a/src/TapRating.tsx b/src/TapRating.tsx index 73a0d17..a4a6065 100644 --- a/src/TapRating.tsx +++ b/src/TapRating.tsx @@ -95,6 +95,11 @@ export type TapRatingProps = { * Pass in a custom base image source */ starImage?: string; + + /** + * Testing ID for Jest + */ + testId?: string; }; const TapRating: React.FunctionComponent = (props) => { @@ -126,7 +131,7 @@ const TapRating: React.FunctionComponent = (props) => { setPosition(position); }; - const { count, reviews, showRating, reviewColor, reviewSize } = props; + const { count, reviews, showRating, reviewColor, reviewSize, testID } = props; const rating_array = []; const starContainerStyle = [styles.starContainer]; @@ -143,6 +148,7 @@ const TapRating: React.FunctionComponent = (props) => { _.times(count, (index) => { rating_array.push( { @@ -155,9 +161,10 @@ const TapRating: React.FunctionComponent = (props) => { }); return ( - + {showRating && ( = (props) => { {reviews[position - 1]} )} - {renderStars(rating_array)} + + {renderStars(rating_array)} + ); }; @@ -178,6 +187,7 @@ TapRating.defaultProps = { showRating: true, reviewColor: "rgba(230, 196, 46, 1)", reviewSize: 25, + testID: "rating", }; const styles = StyleSheet.create({ diff --git a/src/components/Star.tsx b/src/components/Star.tsx index 2fe1a85..6441b0e 100644 --- a/src/components/Star.tsx +++ b/src/components/Star.tsx @@ -21,6 +21,7 @@ export type StarProps = { starStyle?: StyleProp; position?: number; starSelectedInPosition?: ( number ) => void; + testId?: string; }; const Star: React.FunctionComponent = props => { @@ -51,14 +52,20 @@ const Star: React.FunctionComponent = props => { selectedColor, unSelectedColor, isDisabled, - starStyle + starStyle, + testId } = props; const starSource = fill && selectedColor === null ? STAR_SELECTED_IMAGE : starImage; return ( - +