-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an integration tests for voting component - Closes #290 #476
Create an integration tests for voting component - Closes #290 #476
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the PR is still in progress
, which is why I want to make two suggestions before there are more tests that they need to be applied to:
- Use https://github.com/producthunt/chai-enzyme for assertions, because then it gives a more descriptive error message if the assertion fails then just "Expected false to be true". Some examples are below.
- Use atomic steps. "When ..." step should usually only simulate something (e.g. a click), "Then ..." step should usually only make an assertion. If one step first simulates and then
expect
s something. E.g. 'Then I confirm my votes' should be two steps 'When I confirm my votes' and 'Then I see a confirmation message' . The step definitions then can be in separate reusable functions like here:
https://github.com/LiskHQ/lisk-hub/blob/df5a7e3e52dfc662eccd6879917071082f747bba/test/integration/wallet.test.js#L216-L225
test/integration/voting.test.js
Outdated
step('I\'m logged in as "genesis"', () => { loginProcess(); }); | ||
|
||
step('And next button should be disabled', () => { | ||
expect(wrapper.find('button.next').props().disabled).to.be.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as
expect(wrapper.find('button.next')).to.have.prop('disabled', true);
https://github.com/producthunt/chai-enzyme#propkey-val
test/integration/voting.test.js
Outdated
}); | ||
|
||
step('Then I must be able to go to next step', () => { | ||
expect(wrapper.find('button.confirm').exists()).to.be.equal(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better as
expect(wrapper.find('button.confirm')).to.be.not.present();
For the same reason as above.
https://github.com/producthunt/chai-enzyme#present
test/integration/voting.test.js
Outdated
account, | ||
}); | ||
wrapper.find('button.confirm').simulate('click'); | ||
expect(wrapper.find('h2.result-box-header').text()).to.be.equal(expectedValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/integration/voting.test.js
Outdated
step('I\'m logged in as "genesis"', () => { loginProcess([delegates[0]]); }); | ||
|
||
step('And I should see 3 rows', () => { | ||
expect(wrapper.find('ul.delegate-row')).to.have.lengthOf(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the problem?
There wasn't any integration tests for voting component
-this PR also covers issue #484
Review checklist