import React from 'react';
import Tab from '../../src/react/Tab.js';
import Tabs from '../../src/react/Tabs.js';
import renderer from 'react-test-renderer';
import {mount} from 'enzyme';
class TabsForm extends React.Component {
constructor(props) {
super(props);
this.state = {tabId: '1'};
this.handleChange = this.handleChange.bind(this);
}
handleChange(val) {
this.setState({tabId: val});
}
render() {
return (
);
}
}
describe('Tabs', () => {
test('Tabs - basic rendering', () => {
const tabs = renderer.create().toJSON();
expect(tabs).toMatchSnapshot();
});
test('Tabs - when active tab id is changed, the respective tab is shown', () => {
const tabs = mount();
expect(tabs.instance().tabsInst.props.activeTab).toEqual('1');
expect(tabs.find('.sdc-tab-content').text()).toEqual('Tab #1');
expect(tabs.find('li[data-test-id="1"]').hasClass('sdc-tab-active')).toBeTruthy();
tabs.find('li[data-test-id="2"]').simulate('click');
expect(tabs.instance().tabsInst.props.activeTab).toEqual('2');
expect(tabs.find('li[data-test-id="2"]').hasClass('sdc-tab-active')).toBeTruthy();
expect(tabs.find('li[data-test-id="1"]').hasClass('sdc-tab-active')).not.toBeTruthy();
expect(tabs.find('.sdc-tab-content').text()).toEqual('Tab #2');
});
});