From 44167e9b64e93cd0cf7fee33020f5ac35dbd9026 Mon Sep 17 00:00:00 2001 From: karl Date: Thu, 28 Mar 2024 10:57:34 +0100 Subject: [PATCH 1/4] feat: added testIDs for TapRating --- src/TapRating.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/TapRating.tsx b/src/TapRating.tsx index 73a0d17..24f0ec7 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( { @@ -158,6 +164,7 @@ const TapRating: React.FunctionComponent = (props) => { {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({ From def7601ccf63f73ddd7a03910e83d621c7beaf59 Mon Sep 17 00:00:00 2001 From: karl Date: Thu, 28 Mar 2024 11:02:51 +0100 Subject: [PATCH 2/4] chore: add another container ID for the main view --- src/TapRating.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TapRating.tsx b/src/TapRating.tsx index 24f0ec7..0a00821 100644 --- a/src/TapRating.tsx +++ b/src/TapRating.tsx @@ -161,7 +161,7 @@ const TapRating: React.FunctionComponent = (props) => { }); return ( - + {showRating && ( Date: Mon, 15 Apr 2024 16:53:44 +0200 Subject: [PATCH 3/4] chore: change testIds to use camelcase and match style names --- src/TapRating.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TapRating.tsx b/src/TapRating.tsx index 0a00821..a4a6065 100644 --- a/src/TapRating.tsx +++ b/src/TapRating.tsx @@ -99,7 +99,7 @@ export type TapRatingProps = { /** * Testing ID for Jest */ - testID?: string; + testId?: string; }; const TapRating: React.FunctionComponent = (props) => { @@ -161,7 +161,7 @@ const TapRating: React.FunctionComponent = (props) => { }); return ( - + {showRating && ( = (props) => { {reviews[position - 1]} )} - + {renderStars(rating_array)} From c849ad45c81ffee558f7666f6f28552baa459857 Mon Sep 17 00:00:00 2001 From: karl Date: Mon, 15 Apr 2024 16:58:09 +0200 Subject: [PATCH 4/4] feat: add test id to touchable opacity in Star.tsx --- src/components/Star.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 ( - +