Add testID for radio item option

This commit is contained in:
Joseph Baylon
2023-02-02 14:39:57 -08:00
committed by Elisabeth Kulzer
parent bda9b10d7d
commit 21ae37353e
2 changed files with 8 additions and 2 deletions

View File

@@ -175,10 +175,12 @@ const OptionItem = ({
/>
);
} else if (type === OptionType.RADIO) {
const radioComponentTestId = selected ? `${testID}.selected` : `${testID}.not_selected`;
radioComponent = (
<RadioItem
selected={Boolean(selected)}
{...radioItemProps}
testID={radioComponentTestId}
/>
);
} else if (type === OptionType.TOGGLE) {

View File

@@ -38,8 +38,9 @@ const getStyleSheet = makeStyleSheetFromTheme((theme) => {
export type RadioItemProps = {
selected: boolean;
checkedBody?: boolean;
testID?: string;
}
const RadioItem = ({selected, checkedBody}: RadioItemProps) => {
const RadioItem = ({selected, checkedBody, testID}: RadioItemProps) => {
const theme = useTheme();
const styles = getStyleSheet(theme);
@@ -60,7 +61,10 @@ const RadioItem = ({selected, checkedBody}: RadioItemProps) => {
}, [checkedBody]);
return (
<View style={[styles.ring, !selected && styles.inActive]}>
<View
style={[styles.ring, !selected && styles.inActive]}
testID={testID}
>
{selected && getBody()}
</View>
);