Skip to content

Commit

Permalink
✅ add test to showFeedback param
Browse files Browse the repository at this point in the history
  • Loading branch information
faival committed Aug 24, 2018
1 parent e4f1d04 commit a62524f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = function (config) {
'src/store/reducers/liskService.js',
'src/actions/transactions.js',
'src/components/errorBoundary/index.js',
'src/components/feedbackForm/**/*.js',
],
overrides: {
'src/store/**/*.js': {
Expand Down
9 changes: 1 addition & 8 deletions src/components/feedbackForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ import actionTypes from '../../constants/actions';
import { feedbackDialogDisplayed, dialogHidden } from '../../actions/dialog';
import FeedbackFrom from './feedbackForm';

export const mapStateToProps = state => ({
toasts: state.toaster || [],
});

export const mapDispatchToProps = dispatch => ({
hideDialog: () => dispatch(dialogHidden()),
showDialog: data => dispatch(feedbackDialogDisplayed(data)),
sendFeedback: data => dispatch({ data, type: actionTypes.sendFeedback }),
});

export default connect(
mapStateToProps,
mapDispatchToProps,
)(translate()(FeedbackFrom));
export default connect(null, mapDispatchToProps)(translate()(FeedbackFrom));
4 changes: 2 additions & 2 deletions src/components/feedbackForm/questionare.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

import styles from './questionare.css';
import Input from '../toolbox/inputs/input';
import { Button, RedButton } from '../toolbox/buttons/button';
import { Button, PrimaryButton } from '../toolbox/buttons/button';
import RadioSelector from './radioSelector';
import { getDeviceMetadata } from '../../utils/app';

Expand Down Expand Up @@ -85,7 +85,7 @@ class Questionare extends React.Component {
<Button label={this.props.t('Cancel')}
onClick={() => this.props.onCancel()}
className='cancel-button' />
<RedButton label={this.props.t('Send')} disabled={!this.state.rating}
<PrimaryButton label={this.props.t('Send')} disabled={!this.state.rating}
onClick={() => this.props.onSubmit(this.state).bind(this)}
className='send-button'/>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/components/mainMenu/mainMenu.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { expect } from 'chai';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import { Tab, Tabs as ToolboxTabs } from 'react-toolbox';
import { MemoryRouter } from 'react-router-dom';
import configureMockStore from 'redux-mock-store';
Expand Down Expand Up @@ -54,6 +54,7 @@ describe('MainMenu', () => {
history: PropTypes.object.isRequired,
i18n: PropTypes.object.isRequired,
},
lifecycleExperimental: true,
};
let clock;

Expand Down Expand Up @@ -113,6 +114,8 @@ describe('MainMenu', () => {
const wrapper = mount(<MemoryRouter>
<MainMenu {...props} />
</MemoryRouter>, options);

expect(wrapper).to.not.have.descendants('#feedback');
wrapper.find(Tab).at(1).simulate('click');
expect(history.push).to.have.been.calledWith(`${routes.wallet.path}`);
});
Expand All @@ -126,4 +129,11 @@ describe('MainMenu', () => {
wrapper.update();
expect(wrapper.find('Drawer').props().active).to.be.equal(true);
});

it('should show feedback when param in url', () => {
const wrapper = shallow(<MainMenu {...props} />, options);
wrapper.setProps({ history: { location: { pathname: `${routes.wallet.path}`, search: '?showFeedback=true' } } });
wrapper.update();
expect(wrapper.find('#feedback').first().props().disabled).to.be.equal(false);
});
});
1 change: 1 addition & 0 deletions src/constants/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const actionTypes = {
searchVotes: 'SEARCH_VOTES',
searchVoters: 'SEARCH_VOTERS',
searchUpdateLast: 'SEARCH_UPDATE_LAST',
sendFeedback: 'SEND_FEEDBACK',
transactionsFailed: 'TRANSACTIONS_FAILED',
transactionsUpdated: 'TRANSACTIONS_UPDATED',
transactionsLoad: 'TRANSACTIONS_LOAD',
Expand Down

0 comments on commit a62524f

Please sign in to comment.