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, {
|
|
|
|
propsData: props,
|
|
|
|
listeners: {
|
|
|
|
visibleChange: () => {},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
const dropdownProps = wrapper.find({ name: 'ADropdown' }).props();
|
2018-06-17 07:57:09 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
Object.keys(props).forEach(key => {
|
|
|
|
expect(dropdownProps[key]).toBe(props[key]);
|
|
|
|
});
|
|
|
|
});
|
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", () => {
|
2019-01-02 12:33:06 +00:00
|
|
|
const wrapper = mount({
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2019-01-02 12:33:06 +00:00
|
|
|
return (
|
|
|
|
<Dropdown.Button
|
2019-01-12 03:33:27 +00:00
|
|
|
overlay={
|
|
|
|
<Menu>
|
|
|
|
<Menu.Item>foo</Menu.Item>
|
|
|
|
</Menu>
|
|
|
|
}
|
2019-01-02 12:33:06 +00:00
|
|
|
/>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2019-01-02 12:33:06 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
|
|
|
const dropdownProps = wrapper.find({ name: 'ADropdown' }).props();
|
2018-06-17 07:57:09 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
expect('visible' in dropdownProps).toBe(false);
|
|
|
|
});
|
|
|
|
});
|