File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,15 +181,15 @@ describe('MenuItem', () => {
181181 ) ;
182182 } ) ;
183183
184- it ( 'should pass itemData in onSelect and onClick with items ' , ( ) => {
184+ it ( 'should only pass defined itemData properties in onSelect and onClick' , ( ) => {
185185 const onSelect = jest . fn ( ) ;
186186 const onClick = jest . fn ( ) ;
187187 const { container } = render (
188188 < Menu
189189 onSelect = { onSelect }
190190 onClick = { onClick }
191191 selectable
192- items = { [ { key : '1' , label : 'Menu Item' } ] }
192+ items = { [ { key : '1' , label : 'Menu Item' , foo : '123' } ] as any }
193193 /> ,
194194 ) ;
195195
@@ -203,6 +203,14 @@ describe('MenuItem', () => {
203203 } ) ,
204204 } ) ,
205205 ) ;
206+ expect ( onSelect ) . toHaveBeenCalledWith (
207+ expect . objectContaining ( {
208+ key : '1' ,
209+ itemData : expect . not . objectContaining ( {
210+ foo : '123' ,
211+ } ) ,
212+ } ) ,
213+ ) ;
206214 expect ( onClick ) . toHaveBeenCalledWith (
207215 expect . objectContaining ( {
208216 key : '1' ,
@@ -212,6 +220,14 @@ describe('MenuItem', () => {
212220 } ) ,
213221 } ) ,
214222 ) ;
223+ expect ( onClick ) . toHaveBeenCalledWith (
224+ expect . objectContaining ( {
225+ key : '1' ,
226+ itemData : expect . not . objectContaining ( {
227+ foo : '123' ,
228+ } ) ,
229+ } ) ,
230+ ) ;
215231 } ) ;
216232 } ) ;
217233
You can’t perform that action at this time.
0 commit comments