diff --git a/tests/MenuItem.spec.js b/tests/MenuItem.spec.js index b87064c7..1e65bc5c 100644 --- a/tests/MenuItem.spec.js +++ b/tests/MenuItem.spec.js @@ -2,7 +2,7 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import KeyCode from 'rc-util/lib/KeyCode'; -import Menu, { MenuItem } from '../src'; +import Menu, { MenuItem, MenuItemGroup, SubMenu } from '../src'; import { MenuItem as NakedMenuItem } from '../src/MenuItem'; @@ -81,4 +81,35 @@ describe('MenuItem', () => { expect(onMouseLeave).toHaveBeenCalledWith({ key, domEvent }); }); }); + + describe('rest props', () => { + it('can render all props to sub component', () => { + const onClick = jest.fn(); + const restProps = { + onClick, + 'data-whatever': 'whatever', + title: 'title', + className: 'className', + style: { fontSize: 20 }, + }; + const wrapper = mount( +
+ ); + expect(wrapper.render()).toMatchSnapshot(); + wrapper.find('MenuItem').at(0).simulate('click'); + expect(onClick).toHaveBeenCalledTimes(1); + wrapper.find('SubMenu').at(0).simulate('click'); + expect(onClick).toHaveBeenCalledTimes(2); + wrapper.find('MenuItemGroup').at(0).simulate('click'); + expect(onClick).toHaveBeenCalledTimes(3); + }); + }); }); diff --git a/tests/__snapshots__/MenuItem.spec.js.snap b/tests/__snapshots__/MenuItem.spec.js.snap new file mode 100644 index 00000000..3fb01614 --- /dev/null +++ b/tests/__snapshots__/MenuItem.spec.js.snap @@ -0,0 +1,67 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`MenuItem rest props can render all props to sub component 1`] = ` + +`;