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

Commit

Permalink
Merge pull request #842 from LiskHQ/840-voting-submit-on-enter
Browse files Browse the repository at this point in the history
Remove submitting on enter in vote form - Closes #840
  • Loading branch information
gina contrino authored Oct 6, 2017
2 parents 1cc1fcd + 3cbbc74 commit afaa600
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/components/voteDialog/voteDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class VoteDialog extends React.Component {
});
return (
<article>
<form onSubmit={this.confirm.bind(this)}>
<form id='voteform'>
<Autocomplete
votedDelegates={this.props.delegates}
votes={this.props.votes}
Expand All @@ -77,8 +77,9 @@ export default class VoteDialog extends React.Component {
}}
primaryButton={{
label: this.props.t('Confirm'),
onClick: this.confirm.bind(this),
fee: Fees.vote,
type: 'submit',
type: 'button',
disabled: (
totalVotes > maxCountOfVotes ||
votesList.length === 0 ||
Expand Down
10 changes: 8 additions & 2 deletions src/components/voteDialog/voteDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ describe('VoteDialog', () => {
expect(wrapper.find('ActionBar')).to.have.lengthOf(1);
});

it('should not submit form on enter press', () => {
wrapper.find('#voteform').simulate('submit');

expect(props.votePlaced).not.to.have.been.calledWith();
});

it('should fire votePlaced action if lists are not empty and account balance is sufficient', () => {
wrapper.find('VoteDialog .primary-button button').simulate('submit');
wrapper.find('VoteDialog .primary-button button').simulate('click');

expect(props.votePlaced).to.have.been.calledWith({
account: ordinaryAccount,
Expand Down Expand Up @@ -109,7 +115,7 @@ describe('VoteDialog', () => {
wrapper = mount(<VoteDialog {...props} account={accountWithSecondPassphrase} />, options);
const secondPassphrase = 'test second passphrase';
wrapper.instance().handleChange('secondPassphrase', secondPassphrase);
wrapper.find('.primary-button button').simulate('submit');
wrapper.find('.primary-button button').simulate('click');

expect(props.votePlaced).to.have.been.calledWith({
activePeer: props.activePeer,
Expand Down

0 comments on commit afaa600

Please sign in to comment.