Skip to content

Commit 44e118b

Browse files
author
刘欢
committed
feat: update MenuItem test to include itemData handling in onSelect and onClick
1 parent f9a72c6 commit 44e118b

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

tests/MenuItem.spec.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)