You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

8 years ago
import React from 'react';
import { mount, render } from 'enzyme';
8 years ago
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}>
6 years ago
<TabPane tab="foo" key="1">
foo
</TabPane>
{undefined}
{null}
{false}
6 years ago
</Tabs>,
8 years ago
);
});
it('add card', () => {
6 years ago
wrapper
.find('.ant-tabs-new-tab')
.hostNodes()
.simulate('click');
8 years ago
expect(handleEdit.mock.calls[0][1]).toBe('add');
});
it('remove card', () => {
wrapper.find('.anticon-close').simulate('click');
expect(handleEdit).toHaveBeenCalledWith('1', 'remove');
8 years ago
});
it('validateElement', () => {
expect(wrapper.find('.ant-tabs-tab').length).toBe(1);
});
8 years ago
});
describe('tabPosition', () => {
it('remove card', () => {
const wrapper = render(
<Tabs tabPosition="left" tabBarExtraContent="xxx">
6 years ago
<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>}>
6 years ago
<TabPane tab="foo" key="1">
foo
</TabPane>
</Tabs>,
);
expect(wrapper).toMatchSnapshot();
});
});
8 years ago
});