Skip to content

Commit

Permalink
[chore] Add optional switchTestID to ListItemSwitch (#256)
Browse files Browse the repository at this point in the history
## Short description
This PR add the `switchTestID` to `ListItemSwitch` in order for tests to
directly retrieve the switch value

## List of changes proposed in this pull request
- `switchTestID`property on `ListItemSwitch`that is later assigned as
`testID` to the internal `NativeSwitch`component
  • Loading branch information
Vangaorth authored May 3, 2024
1 parent 33e0987 commit 0e93f87
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/listitems/ListItemSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type PartialProps = WithTestID<{
action?: SwitchAction;
isLoading?: boolean;
badge?: Badge;
switchTestID?: string;
}>;

export type SwitchAction = {
Expand Down Expand Up @@ -55,6 +56,7 @@ export const ListItemSwitch = React.memo(
isLoading,
badge,
onSwitchValueChange,
switchTestID,
testID
}: ListItemSwitchProps) => {
const theme = useIOTheme();
Expand Down Expand Up @@ -167,6 +169,7 @@ export const ListItemSwitch = React.memo(
value={value}
accessibilityLabel={label}
onValueChange={onSwitchValueChange}
testID={switchTestID}
/>
)}
</View>
Expand Down

0 comments on commit 0e93f87

Please sign in to comment.