import React from 'react';
import TabView from '../components/Tabs/TabView';
import { shallow, mount } from 'enzyme';
import { Tab, TabContent } from '../components/Tabs/style';
describe('', () => {
let props;
let mountedTab;
const tabView = () => {
if (!mountedTab) {
return mount();
}
return mountedTab;
};
beforeEach(() => {
props = {
data: undefined
};
mountedTab = undefined;
});
it('Default active on the first tab and not active on the rest', () => {
const tab = tabView().find(Tab);
expect(tab.at(0).prop('isActive')).toBe(true);
expect(tab.at(1).prop('isActive')).toBe(false);
expect(tabView().find('TabGroup').length).toBe(1);
});
it('Default active content is correct', () => {
const data = {
tabs: ['one', 'two', 'thre'],
content: ['1', '2', '3']
};
props = { data };
const tabContent = tabView().find(TabContent);
expect(tabContent.text()).toBe('1');
});
it('Click on the inactive tab activate the tab', () => {
const data = {
tabs: ['one', 'two', 'thre'],
content: ['1', '2', '3']
};
props = {
data
};
const tabViewWindow = tabView();
const tab1 = tabViewWindow.find(Tab).at(1);
const tab1Activated = tab1.simulate('click');
expect(tab1Activated.prop('isActive')).toBe(true);
const tabContent = tabViewWindow.find(TabContent);
expect(tabContent.render().text()).toBe('2');
});
});