@@ -37,6 +37,58 @@ describe('Picker', () => {
3737 jest . clearAllMocks ( ) ;
3838 } ) ;
3939
40+ describe ( 'Items' , ( ) => {
41+ const testItems = [ { key : 'one' , value : 1 , label : 'One' , testID : 'item_one' } , { key : 'two' , value : 2 , label : 'Two' , testID : 'item_two' } ] ;
42+ const testItemExists = ( TestCase : ( ) => React . JSX . Element ) => {
43+ const renderTree = render ( < TestCase /> ) ;
44+ const driver = PickerDriver ( { renderTree, testID} , false ) ;
45+ driver . open ( ) ;
46+ const item = driver . itemDriver ( testItems [ 0 ] . testID ) ;
47+ expect ( item . exists ( ) ) . toBeTruthy ( ) ;
48+ } ;
49+
50+ it ( 'should render picker items when passing children' , ( ) => {
51+ const TestCase = ( ) => {
52+ return (
53+ < Picker testID = { testID } >
54+ < Picker . Item { ...testItems [ 0 ] } />
55+ < Picker . Item { ...testItems [ 1 ] } />
56+ </ Picker >
57+ ) ;
58+ } ;
59+ testItemExists ( TestCase ) ;
60+ } ) ;
61+
62+ it ( 'should render picker items when passing items' , ( ) => {
63+ const TestCase = ( ) => {
64+ return (
65+ < Picker testID = { testID } items = { testItems } />
66+ ) ;
67+ } ;
68+ testItemExists ( TestCase ) ;
69+ } ) ;
70+
71+ it ( 'should render picker items with one option when passing one child' , ( ) => {
72+ const TestCase = ( ) => {
73+ return (
74+ < Picker testID = { testID } >
75+ < Picker . Item { ...testItems [ 0 ] } />
76+ </ Picker >
77+ ) ;
78+ } ;
79+ testItemExists ( TestCase ) ;
80+ } ) ;
81+
82+ it ( 'should render picker with one option when passing one item' , ( ) => {
83+ const TestCase = ( ) => {
84+ return (
85+ < Picker testID = { testID } items = { [ testItems [ 0 ] ] } />
86+ ) ;
87+ } ;
88+ testItemExists ( TestCase ) ;
89+ } ) ;
90+ } ) ;
91+
4092 describe ( 'Modal' , ( ) => {
4193 describe ( 'Test open' , ( ) => {
4294 it ( 'Should open when enabled' , ( ) => {
0 commit comments