Skip to content

Commit b098d46

Browse files
authored
Expandable testids (#2784)
* Added testid to the expandablesection * added the testids in the api files * Removed testid from touchable opacity
1 parent 8f442e2 commit b098d46

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/expandableSection/expandableSection.api.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"name": "onPress",
1616
"type": "() => void",
1717
"description": "Called when pressing the header of the ExpandableSection"
18-
}
18+
},
19+
{"name": "testID","type": "string","description": "testing identifier"}
1920
],
2021
"snippet": [
2122
"<ExpandableSection",

src/components/expandableSection/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export type ExpandableSectionProps = {
2525
* action for when pressing the header of the expandableSection
2626
*/
2727
onPress?: () => void;
28+
/**
29+
* Testing identifier
30+
*/
31+
testID?: string;
2832
};
2933

3034
/**
@@ -34,7 +38,7 @@ export type ExpandableSectionProps = {
3438
*/
3539

3640
function ExpandableSection(props: ExpandableSectionProps) {
37-
const {expanded, sectionHeader, children, top} = props;
41+
const {expanded, sectionHeader, children, top, testID} = props;
3842

3943
/**
4044
* TODO: move to reanimated LayoutAnimation after updating to version 2.3.0
@@ -60,7 +64,7 @@ function ExpandableSection(props: ExpandableSectionProps) {
6064
return (
6165
<View style={styles.container}>
6266
{top && expanded && children}
63-
<TouchableOpacity onPress={onPress} accessibilityState={accessibilityState}>
67+
<TouchableOpacity onPress={onPress} testID={testID} accessibilityState={accessibilityState}>
6468
{sectionHeader}
6569
</TouchableOpacity>
6670
{!top && expanded && children}

0 commit comments

Comments
 (0)