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}>
|
2018-12-07 16:17:45 +08:00
|
|
|
<TabPane tab="foo" key="1">
|
|
|
|
foo
|
|
|
|
</TabPane>
|
|
|
|
</Tabs>,
|
2017-03-02 00:16:37 +08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('add card', () => {
|
2018-12-07 16:17:45 +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');
|
2019-04-03 15:54:26 +08:00
|
|
|
expect(handleEdit).toHaveBeenCalledWith('1', 'remove');
|
2017-03-02 00:16:37 +08:00
|
|
|
});
|
|
|
|
});
|
2017-08-05 23:01:28 +08:00
|
|
|
|
|
|
|
describe('tabPosition', () => {
|
|
|
|
it('remove card', () => {
|
2018-07-11 19:31:36 +08:00
|
|
|
const wrapper = render(
|
2017-08-05 23:01:28 +08:00
|
|
|
<Tabs tabPosition="left" tabBarExtraContent="xxx">
|
2018-12-07 16:17:45 +08:00
|
|
|
<TabPane tab="foo" key="1">
|
|
|
|
foo
|
|
|
|
</TabPane>
|
|
|
|
</Tabs>,
|
2017-08-05 23:01:28 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2018-08-28 18:56:25 +08:00
|
|
|
|
|
|
|
describe('renderTabBar', () => {
|
|
|
|
it('custom-tab-bar', () => {
|
|
|
|
const wrapper = render(
|
|
|
|
<Tabs renderTabBar={() => <div>custom-tab-bar</div>}>
|
2018-12-07 16:17:45 +08:00
|
|
|
<TabPane tab="foo" key="1">
|
|
|
|
foo
|
|
|
|
</TabPane>
|
|
|
|
</Tabs>,
|
2018-08-28 18:56:25 +08:00
|
|
|
);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
2017-03-02 00:16:37 +08:00
|
|
|
});
|