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

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-03-02 00:16:37 +08:00
import React from 'react';
2018-07-11 19:31:36 +08:00
import { mount, render } from 'enzyme';
2017-03-02 00:16:37 +08:00
import Tabs from '..';
const { TabPane } = Tabs;
describe('Tabs', () => {
describe('editable-card', () => {
let handleEdit;
let wrapper;
beforeEach(() => {
handleEdit = jest.fn();
wrapper = mount(
<Tabs type="editable-card" onEdit={handleEdit}>
<TabPane tab="foo" key="1">foo</TabPane>
</Tabs>
);
});
it('add card', () => {
2017-09-20 16:26:18 +08:00
wrapper.find('.ant-tabs-new-tab').hostNodes().simulate('click');
2017-03-02 00:16:37 +08:00
expect(handleEdit.mock.calls[0][1]).toBe('add');
});
it('remove card', () => {
wrapper.find('.anticon-close').simulate('click');
expect(handleEdit).toBeCalledWith('1', 'remove');
});
});
describe('tabPosition', () => {
it('remove card', () => {
2018-07-11 19:31:36 +08:00
const wrapper = render(
<Tabs tabPosition="left" tabBarExtraContent="xxx">
<TabPane tab="foo" key="1">foo</TabPane>
</Tabs>
);
expect(wrapper).toMatchSnapshot();
});
});
describe('renderTabBar', () => {
it('custom-tab-bar', () => {
const wrapper = render(
<Tabs renderTabBar={() => <div>custom-tab-bar</div>}>
<TabPane tab="foo" key="1">foo</TabPane>
</Tabs>
);
expect(wrapper).toMatchSnapshot();
});
});
2017-03-02 00:16:37 +08:00
});