Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit ddad635

Browse files
Asad520AsadShabir
andauthored
test: testID added in TabBar for testing (#1394)
* test: testID prop added to TabBar Co-authored-by: AsadShabir <asadshabir@A006-00143.local>
1 parent 69425a8 commit ddad635

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ Style to apply to the tab bar container.
530530

531531
Define a spacing between tabs.
532532

533+
##### `testID`
534+
535+
Test id for the tabBar. Can be used for scrolling the tab bar in tests
536+
533537
## Using with other libraries
534538

535539
### [React Navigation](https://github.com/react-navigation/react-navigation)

src/TabBar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export type Props<T extends Route> = SceneRendererProps & {
6262
contentContainerStyle?: StyleProp<ViewStyle>;
6363
style?: StyleProp<ViewStyle>;
6464
gap?: number;
65+
testID?: string;
6566
};
6667

6768
type FlattenedTabWidth = string | number | undefined;
@@ -274,6 +275,7 @@ export default function TabBar<T extends Route>({
274275
renderTabBarItem,
275276
style,
276277
tabStyle,
278+
testID,
277279
}: Props<T>) {
278280
const [layout, setLayout] = React.useState<Layout>({ width: 0, height: 0 });
279281
const [tabWidths, setTabWidths] = React.useState<Record<string, number>>({});
@@ -548,6 +550,7 @@ export default function TabBar<T extends Route>({
548550
renderItem={renderItem}
549551
onScroll={handleScroll}
550552
ref={flatListRef}
553+
testID={testID}
551554
/>
552555
</View>
553556
</Animated.View>

0 commit comments

Comments
 (0)