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

58 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import Dropdown from '..';
import Menu from '../../menu';
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
};
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
});
});
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-12 03:33:27 +00:00
});
2020-07-30 07:41:54 +00:00
const dropdownProps = wrapper.findComponent({ name: 'ADropdown' }).props();
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
});