2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Dropdown from '..';
|
|
|
|
import Menu from '../../menu';
|
2018-06-17 07:57:09 +00:00
|
|
|
|
|
|
|
describe('DropdownButton', () => {
|
|
|
|
it('pass appropriate props to Dropdown', () => {
|
|
|
|
const props = {
|
|
|
|
align: {
|
|
|
|
offset: [10, 20],
|
|
|
|
},
|
|
|
|
disabled: false,
|
|
|
|
trigger: ['hover'],
|
|
|
|
visible: true,
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-06-17 07:57:09 +00:00
|
|
|
|
|
|
|
const wrapper = mount(Dropdown.Button, {
|
2020-07-25 07:46:49 +00:00
|
|
|
props,
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2020-07-30 07:41:54 +00:00
|
|
|
const dropdownProps = wrapper.findComponent({ name: 'ADropdown' }).props();
|
2019-01-12 03:33:27 +00:00
|
|
|
Object.keys(props).forEach(key => {
|
2020-07-30 07:41:54 +00:00
|
|
|
expect(dropdownProps[key]).toStrictEqual(props[key]);
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
});
|
2018-06-17 07:57:09 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
it("don't pass visible to Dropdown if it's not exits", () => {
|
2020-07-30 07:41:54 +00:00
|
|
|
const wrapper = mount(Dropdown.Button, {
|
|
|
|
props: {
|
|
|
|
overlay: (
|
|
|
|
<Menu>
|
|
|
|
<Menu.Item>foo</Menu.Item>
|
|
|
|
</Menu>
|
|
|
|
),
|
2019-01-02 12:33:06 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2020-07-30 07:41:54 +00:00
|
|
|
const dropdownProps = wrapper.findComponent({ name: 'ADropdown' }).props();
|
2018-06-17 07:57:09 +00:00
|
|
|
|
2020-07-30 07:41:54 +00:00
|
|
|
expect(dropdownProps.visible).toBe(undefined);
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2019-04-10 02:09:00 +00:00
|
|
|
|
|
|
|
it('should support href like Button', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Dropdown.Button
|
|
|
|
href="https://ant.design"
|
|
|
|
overlay={
|
|
|
|
<Menu>
|
|
|
|
<Menu.Item>foo</Menu.Item>
|
|
|
|
</Menu>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|