Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testIDs prop to SegmentedControl #19

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@department-of-veterans-affairs/mobile-component-library",
"version": "0.0.18",
"version": "0.0.19",
"description": "VA Design System Mobile Component Library",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const twoSegments: Story = {
'You have 3 unread messages. Review messages in your inbox',
'Review your folders',
],
testIDs: ['test-id-1', 'test-id-2'],
},
parameters: {
design: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export type SegmentedControlProps = {
a11yLabels?: string[]
/** Optional array of segment accessibility hints */
a11yHints?: string[]
/** Optional array of test IDs for test suites */
testIDs?: string[]
}

type SegmentProps = {
Expand All @@ -52,6 +54,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
selected,
a11yLabels,
a11yHints,
testIDs,
}) => {
const { t } = useTranslation()
const colorScheme = useColorScheme()
Expand Down Expand Up @@ -125,6 +128,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
accessibilityValue={accessibilityValue}
accessibilityRole={'tab'}
accessibilityState={{ selected: isSelected }}
testID={testIDs?.[index]}
>
<Text allowFontScaling={false} style={textStyle}>
{label}
Expand Down