mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 07:39:36 +08:00
77c5adbe4d
* init style * support size * editable * add shadow * update demo * fix nest style * update rtl * update snapshot * bump * fix hover * fix test case * fix style lint * clean up * updat docs * add onTabScroll * upgrade rc-dropdown * update snapshot * clean snapshot * clean up Co-authored-by: afc163 <afc163@gmail.com>
89 lines
2.2 KiB
JavaScript
89 lines
2.2 KiB
JavaScript
import React from 'react';
|
|
import { mount, render } from 'enzyme';
|
|
import Tabs from '..';
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
|
|
|
const { TabPane } = Tabs;
|
|
|
|
describe('Tabs', () => {
|
|
mountTest(() => (
|
|
<Tabs>
|
|
<TabPane tab="xx" key="xx" />
|
|
</Tabs>
|
|
));
|
|
rtlTest(() => (
|
|
<Tabs>
|
|
<TabPane tab="xx" key="xx" />
|
|
</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>
|
|
{undefined}
|
|
{null}
|
|
{false}
|
|
</Tabs>,
|
|
);
|
|
});
|
|
|
|
it('add card', () => {
|
|
wrapper.find('.ant-tabs-nav-add').first().simulate('click');
|
|
expect(handleEdit.mock.calls[0][1]).toBe('add');
|
|
});
|
|
|
|
it('remove card', () => {
|
|
wrapper.find('.anticon-close').simulate('click');
|
|
expect(handleEdit).toHaveBeenCalledWith('1', 'remove');
|
|
});
|
|
|
|
it('validateElement', () => {
|
|
expect(wrapper.find('.ant-tabs-tab').length).toBe(1);
|
|
});
|
|
});
|
|
|
|
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();
|
|
});
|
|
});
|
|
|
|
it('warning for onNextClick', () => {
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
mount(<Tabs onNextClick={() => {}} />);
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
'Warning: [antd: Tabs] `onPrevClick` and `onNextClick` has been removed. Please use `onTabScroll` instead.',
|
|
);
|
|
errorSpy.mockRestore();
|
|
});
|
|
});
|