@@ -4,32 +4,18 @@ import {WheelPickerDriver} from '../WheelPicker/WheelPicker.driver';
4
4
import { SectionsWheelPickerProps } from './index' ;
5
5
6
6
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 ) ;
14
9
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 ) {
27
12
return WheelPickerDriver ( {
28
13
renderTree : props . renderTree ,
29
14
testID : `${ props . testID } .${ index } `
30
15
} ) ;
31
- } ) ;
32
- }
16
+ }
17
+ return undefined ;
18
+ } ) . filter ( ( driver ) : driver is ReturnType < typeof WheelPickerDriver > => ! ! driver ) ;
33
19
34
20
return { ...driver , sectionsDrivers} ;
35
21
} ;
0 commit comments