2019-01-03 16:00:55 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { render, mount } from 'enzyme';
|
|
|
|
import { renderToJson } from 'enzyme-to-json';
|
|
|
|
import { Tabs } from '../src';
|
2020-09-02 20:30:47 +03:00
|
|
|
import { tabs, simple10Tabs } from '../src/Tabs/data';
|
2019-01-03 16:00:55 +03:00
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
describe('Tabs', function () {
|
2019-01-03 16:00:55 +03:00
|
|
|
it('renders correctly', () => {
|
2020-09-09 17:35:22 +03:00
|
|
|
const wrapper = render(
|
|
|
|
<Tabs
|
|
|
|
tabs={tabs}
|
|
|
|
onClick={() => {
|
|
|
|
// noop
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2019-01-03 16:00:55 +03:00
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders with props', () => {
|
|
|
|
const wrapper = render(
|
2020-09-09 17:35:22 +03:00
|
|
|
<Tabs
|
|
|
|
tabs={tabs}
|
|
|
|
onClick={() => {
|
|
|
|
// noop
|
|
|
|
}}
|
|
|
|
selected="Tab2"
|
|
|
|
/>
|
2019-01-03 16:00:55 +03:00
|
|
|
);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders tabs without inner components', () => {
|
|
|
|
const wrapper = render(
|
2020-09-09 17:35:22 +03:00
|
|
|
<Tabs
|
|
|
|
tabs={simple10Tabs}
|
|
|
|
onClick={() => {
|
|
|
|
// noop
|
|
|
|
}}
|
|
|
|
selected="5"
|
|
|
|
/>
|
2019-01-03 16:00:55 +03:00
|
|
|
);
|
|
|
|
expect(renderToJson(wrapper)).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should select tab', () => {
|
|
|
|
const onClick = jest.fn();
|
|
|
|
const wrapper = mount(<Tabs tabs={tabs} onClick={onClick} />);
|
|
|
|
|
2020-08-08 23:26:39 +03:00
|
|
|
wrapper.find('button').first().simulate('click');
|
2019-01-03 16:00:55 +03:00
|
|
|
expect(onClick).toBeCalled();
|
|
|
|
});
|
|
|
|
});
|