Skip to content

Commit 3dc4552

Browse files
committed
Changed to take testIDs from children
1 parent 761a672 commit 3dc4552

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

src/components/sectionsWheelPicker/SectionsWheelPicker.driver.tsx

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,18 @@ import {WheelPickerDriver} from '../WheelPicker/WheelPicker.driver';
44
import {SectionsWheelPickerProps} from './index';
55

66

7-
type CustomSectionsTestIds = {
8-
customSectionTestIds?: string[]
9-
};
10-
11-
export const SectionsWheelPickerDriver = (props: ComponentProps & CustomSectionsTestIds) => {
12-
const {customSectionTestIds, ...others} = props;
13-
const driver = useComponentDriver<SectionsWheelPickerProps>(others);
7+
export const SectionsWheelPickerDriver = (props: ComponentProps) => {
8+
const driver = useComponentDriver<SectionsWheelPickerProps>(props);
149

15-
let sectionsDrivers: (ReturnType<typeof WheelPickerDriver>)[];
16-
const {renderTree} = props;
17-
if (customSectionTestIds) {
18-
sectionsDrivers = customSectionTestIds.map(testID => {
19-
return WheelPickerDriver({
20-
renderTree,
21-
testID
22-
});
23-
});
24-
} else {
25-
// Default sections test ids.
26-
sectionsDrivers = React.Children.toArray(driver.getElement().props.children).map((_section, index) => {
10+
const sectionsDrivers = React.Children.toArray(driver.getElement().props.children).map((_section, index) => {
11+
if (typeof _section === 'object' && 'props' in _section) {
2712
return WheelPickerDriver({
2813
renderTree: props.renderTree,
2914
testID: `${props.testID}.${index}`
3015
});
31-
});
32-
}
16+
}
17+
return undefined;
18+
}).filter((driver): driver is ReturnType<typeof WheelPickerDriver> => !!driver);
3319

3420
return {...driver, sectionsDrivers};
3521
};

0 commit comments

Comments
 (0)