mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
62d68b049f
* feat: Customized bar of tab. * docs: 更新关于renderTabBar的中文文档 * docs: 更新关于renderTabBar的英文文档 * update: 优化代码 * docs: 更新关于renderTabBar的文档 * update: 完善renderTabBar代码 * update: 完成自定义tabBar * docs: 去掉旧的DefaultTabBar参数说明 * update: 修复CI测试 * fix: 去掉>选择器,解决自定义tabBar后样式错误 * update: 优化代码质量 * update: 添加测试 * fix: lint * fix: 避免tab嵌套bug * update: 把DefaultTabBar放在renderTabBar里
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import { mount, render } from 'enzyme';
|
|
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', () => {
|
|
wrapper.find('.ant-tabs-new-tab').hostNodes().simulate('click');
|
|
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', () => {
|
|
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();
|
|
});
|
|
});
|
|
});
|