ant-design-vue/components/tabs/__tests__/index.test.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import Tabs from '..';
2018-06-17 09:25:54 +00:00
2019-01-12 03:33:27 +00:00
const { TabPane } = Tabs;
2018-06-17 09:25:54 +00:00
describe('Tabs', () => {
describe('editable-card', () => {
2019-01-12 03:33:27 +00:00
let handleEdit;
let wrapper;
2018-06-17 09:25:54 +00:00
beforeEach(() => {
2019-01-12 03:33:27 +00:00
handleEdit = jest.fn();
2018-06-17 09:25:54 +00:00
wrapper = mount({
2019-01-12 03:33:27 +00:00
render() {
2018-06-17 09:25:54 +00:00
return (
2019-01-12 03:33:27 +00:00
<Tabs type="editable-card" onEdit={handleEdit}>
<TabPane tab="foo" key="1">
foo
</TabPane>
2018-06-17 09:25:54 +00:00
</Tabs>
2019-01-12 03:33:27 +00:00
);
2018-06-17 09:25:54 +00:00
},
2019-01-12 03:33:27 +00:00
});
});
2018-06-17 09:25:54 +00:00
it('add card', () => {
2019-01-12 03:33:27 +00:00
wrapper.find('.ant-tabs-new-tab').trigger('click');
expect(handleEdit.mock.calls[0][1]).toBe('add');
});
2018-06-17 09:25:54 +00:00
it('remove card', () => {
2019-01-12 03:33:27 +00:00
wrapper.find('.anticon-close').trigger('click');
expect(handleEdit).toBeCalledWith('1', 'remove');
});
});
2018-06-17 09:25:54 +00:00
describe('tabPosition', () => {
it('remove card', () => {
const wrapper = mount({
2019-01-12 03:33:27 +00:00
render() {
2018-06-17 09:25:54 +00:00
return (
2019-01-12 03:33:27 +00:00
<Tabs tabPosition="left" tabBarExtraContent="xxx">
<TabPane tab="foo" key="1">
foo
</TabPane>
2018-06-17 09:25:54 +00:00
</Tabs>
2019-01-12 03:33:27 +00:00
);
2018-06-17 09:25:54 +00:00
},
2019-01-12 03:33:27 +00:00
});
expect(wrapper.html()).toMatchSnapshot();
});
});
});