Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Add unit tests for Tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Jul 28, 2017
1 parent 44d8aac commit ebb9716
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/tabs/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { Provider } from 'react-redux';
import store from '../../store';
import TabsContainer from './index';
import Tabs from './tabs';
describe('TabsContainer', () => {
it('should render Tabs component', () => {
const wrapper = mount(<Provider store={store}><TabsContainer /></Provider>);
expect(wrapper.find(Tabs).exists()).to.equal(true);
});
});
*/
39 changes: 39 additions & 0 deletions src/components/tabs/tabs.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import chai, { expect } from 'chai';
import { mount } from 'enzyme';
import { Tab, Tabs as ToolboxTabs } from 'react-toolbox';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import Tabs from './tabs';

chai.use(sinonChai);

describe('Tabs', () => {
const history = {
location: {
pathname: '/main/voting',
},
push: sinon.spy(),
};

it('should render react toolbox Tabs component', () => {
const wrapper = mount(<Tabs history={history} />);
expect(wrapper.find(ToolboxTabs).exists()).to.equal(true);
});

it('should render 3 Tab components if props.isDelegate', () => {
const wrapper = mount(<Tabs isDelegate={true} history={history} />);
expect(wrapper.find(Tab)).to.have.lengthOf(3);
});

it('should render 2 Tab components if !props.isDelegate', () => {
const wrapper = mount(<Tabs isDelegate={false} history={history} />);
expect(wrapper.find(Tab)).to.have.lengthOf(2);
});

it('should allow to change active tab', () => {
const wrapper = mount(<Tabs isDelegate={false} history={history} />);
wrapper.find(Tab).at(0).simulate('click');
expect(history.push).to.have.been.calledWith('transactions');
});
});

0 comments on commit ebb9716

Please sign in to comment.