ant-design/components/tabs/__tests__/index.test.js
oldchicken 5a7a92af46 fix: children of Tabs[type="editable-card"] cannot be falsy (#17965)
* tabs-editable-card-bugfix

if tabs type ="editable-card",if children has falsy value ,we will get error message,so we should fix it in tabs.

error:https://codesandbox.io/s/lively-glade-jmg5s

* editable-card bugfix

* tabs bugfix

* tabs-editable-card bugfix

* tab bugfix

* bugfix

* delete errorfix

* add test
2019-07-30 16:10:14 +08:00

70 lines
1.6 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>
{undefined}
{null}
{false}
</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).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();
});
});
});