ant-design/components/dropdown/__tests__/dropdown-button.test.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-12-14 14:48:09 +08:00
import React from 'react';
2018-11-26 12:06:42 +08:00
import { mount } from 'enzyme';
2016-12-14 14:48:09 +08:00
import Dropdown from '..';
import Menu from '../../menu';
describe('DropdownButton', () => {
it('pass appropriate props to Dropdown', () => {
const props = {
align: {
offset: [10, 20],
},
overlay: (
<Menu>
<Menu.Item>foo</Menu.Item>
</Menu>
),
disabled: false,
2016-12-14 14:48:09 +08:00
trigger: ['hover'],
visible: true,
onVisibleChange: () => {},
};
2018-11-26 12:06:42 +08:00
const wrapper = mount(<Dropdown.Button {...props} />);
2016-12-14 14:48:09 +08:00
const dropdownProps = wrapper.find(Dropdown).props();
Object.keys(props).forEach((key) => {
expect(dropdownProps[key]).toBe(props[key]); // eslint-disable-line
2016-12-14 14:48:09 +08:00
});
});
it('don\'t pass visible to Dropdown if it\'s not exits', () => {
2018-11-26 12:06:42 +08:00
const menu = (
<Menu>
<Menu.Item>foo</Menu.Item>
</Menu>
);
const wrapper = mount(<Dropdown.Button overlay={menu} />);
2016-12-14 14:48:09 +08:00
const dropdownProps = wrapper.find(Dropdown).props();
expect('visible' in dropdownProps).toBe(false);
});
});