@@ -27,7 +27,7 @@ describe('Select renderOption', () => {
2727 expect ( elementWrapper ) . toHaveTextContent ( 'Custom' ) ;
2828 } ) ;
2929
30- test ( 'receives correct item properties for child option' , ( ) => {
30+ test ( 'receives correct item properties for item option' , ( ) => {
3131 const renderOption = jest . fn ( ( ) => < div > Custom</ div > ) ;
3232 const childOption = { label : 'Test' , value : '1' } ;
3333 const wrapper = renderSelect ( {
@@ -47,7 +47,7 @@ describe('Select renderOption', () => {
4747 } )
4848 ) ;
4949 } ) ;
50- test ( 'receives correct item properties for parent option' , ( ) => {
50+ test ( 'receives correct item properties for group option' , ( ) => {
5151 const renderOption = jest . fn ( ( ) => < div > Custom</ div > ) ;
5252 const groupOption = { label : 'Group' , value : 'g1' , options : [ { label : 'Child' , value : 'c1' } ] } ;
5353 const wrapper = renderSelect ( {
@@ -65,6 +65,30 @@ describe('Select renderOption', () => {
6565 } )
6666 ) ;
6767 } ) ;
68+
69+ test ( 'receives correct item properties for trigger option' , ( ) => {
70+ const renderOption = jest . fn ( ( ) => < div > Custom</ div > ) ;
71+ const selectedOption = { label : 'Test' , value : '1' } ;
72+ const wrapper = renderSelect ( {
73+ options : [ selectedOption ] ,
74+ selectedOption,
75+ triggerVariant : 'option' ,
76+ renderOption,
77+ } ) ;
78+ const triggerWrapper = wrapper . findTrigger ( ) ! ;
79+ expect ( triggerWrapper ) . not . toBeNull ( ) ;
80+ expect ( triggerWrapper . getElement ( ) ) . toHaveTextContent ( 'Custom' ) ;
81+ expect ( renderOption ) . toHaveBeenCalledWith (
82+ expect . objectContaining ( {
83+ filterText : undefined ,
84+ item : expect . objectContaining ( {
85+ type : 'trigger' ,
86+ option : expect . objectContaining ( selectedOption ) ,
87+ } ) ,
88+ } )
89+ ) ;
90+ } ) ;
91+
6892 test ( 'reflects highlighted state' , ( ) => {
6993 const renderOption = jest . fn ( props => < div > { props . item . highlighted ? 'highlighted' : 'normal' } </ div > ) ;
7094 const wrapper = renderSelect ( { options : [ { label : 'First' , value : '1' } ] , renderOption } ) ;
@@ -104,6 +128,30 @@ describe('Select renderOption', () => {
104128 } )
105129 ) ;
106130 } ) ;
131+
132+ test ( 'receives correct parent attribute for child item in group' , ( ) => {
133+ const renderOption = jest . fn ( ( ) => < div > Custom</ div > ) ;
134+ const groupOption = { label : 'Parent Group' , value : 'g1' , options : [ { label : 'Child Item' , value : 'c1' } ] } ;
135+ const wrapper = renderSelect ( {
136+ options : [ groupOption ] ,
137+ renderOption,
138+ } ) ;
139+ wrapper . openDropdown ( ) ;
140+
141+ // Verify that the child item receives the correct parent attribute
142+ expect ( renderOption ) . toHaveBeenCalledWith (
143+ expect . objectContaining ( {
144+ item : expect . objectContaining ( {
145+ type : 'item' ,
146+ option : expect . objectContaining ( { label : 'Child Item' , value : 'c1' } ) ,
147+ parent : expect . objectContaining ( {
148+ type : 'group' ,
149+ option : expect . objectContaining ( groupOption ) ,
150+ } ) ,
151+ } ) ,
152+ } )
153+ ) ;
154+ } ) ;
107155 test ( 'reflects disabled state' , ( ) => {
108156 const renderOption = jest . fn ( props => < div > { props . item . disabled ? 'disabled' : 'enabled' } </ div > ) ;
109157 const wrapper = renderSelect ( {
0 commit comments