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

48 lines
1.1 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, {
propsData: props,
listeners: {
visibleChange: () => {},
},
2019-01-12 03:33:27 +00:00
});
const dropdownProps = wrapper.find({ name: 'ADropdown' }).props();
2019-01-12 03:33:27 +00:00
Object.keys(props).forEach(key => {
expect(dropdownProps[key]).toBe(props[key]);
});
});
2019-01-12 03:33:27 +00:00
it("don't pass visible to Dropdown if it's not exits", () => {
const wrapper = mount({
2019-01-12 03:33:27 +00:00
render() {
return (
<Dropdown.Button
2019-01-12 03:33:27 +00:00
overlay={
<Menu>
<Menu.Item>foo</Menu.Item>
</Menu>
}
/>
2019-01-12 03:33:27 +00:00
);
},
2019-01-12 03:33:27 +00:00
});
const dropdownProps = wrapper.find({ name: 'ADropdown' }).props();
2019-01-12 03:33:27 +00:00
expect('visible' in dropdownProps).toBe(false);
});
});