Skip to content
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

Increase test coverage - Closes #535 #570

Merged
merged 9 commits into from
Mar 26, 2018

Conversation

michaeltomasik
Copy link
Contributor

What was the problem?

Low test coverage

How did I fix it?

Increase test coverage

How to test it?

Run tests to check if coverage is above 80%

Review checklist

@@ -31,4 +32,11 @@ describe('RegisterHOC', () => {
it('should render Register', () => {
expect(wrapper.find('Register')).to.have.lengthOf(1);
});

it('should bind dialogDisplayed action to Register props.dialogDisplayed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setActiveDialog is no longer used in register component, so it can be removed and this test too.

actionsSpy.restore();
});

it('should bind dialogDisplayed action to Login props.dialogDisplayed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setActiveDialog is no longer used in login component, so it can be removed and this test too.

expect(wrapper.find('Search input').props().value).to.equal('');
wrapper.find('Search').props().history.push('/explorer/transaciton/123');
wrapper.update();
expect(wrapper.find('Search input').props().value).to.equal('123');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use https://github.com/producthunt/chai-enzyme#propskey-val as it gives better error messages.

Also applicable for other tests in this file.

it('should change value on "change" event', () => {
wrapper.find('Search input').simulate('change', { target: { value: '12025' } });
expect(wrapper.find('Search input').props().value).to.equal('12025');
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this duplicate to the previous test case?

});

it('should render Search', () => {
expect(wrapper.find('.search-bar-input')).to.have.lengthOf(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});

export default connect(mapStateToProps, mapDispatchToProps)(translate()(Send));
export default connect(mapStateToProps)(translate()(Send));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

<Provider store={{}}>
<Router>
<Sidechains {...props} />
</Router>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

withRouter(..) in the component seems unnecessary as well as <Router> and <Provider> here

<Sidechains {...props} />
</Router>
</Provider>, options);
expect(wrapper.find('Sidechains')).to.have.lengthOf(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of assertion makes sense for a HOC, but not here.
Try rather something like expect(wrapper.find('h2')).to.have.text('Coming soon.')

And then update it(... accordingly.

peers: {},
};
const wrapper = shallow(<TransactionOverview {...props} />);
expect(wrapper.find('Waypoint')).to.have.length(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

karma.conf.js Outdated
@@ -101,6 +89,9 @@ module.exports = function (config) {
'src/components/mainMenu/mainMenu.js',
'src/components/setting/setting.js',
'src/components/votesPreview/index.js',
'src/components/register/index.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has some tests added below. Does it still need to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It does not cover 80%. As far as I remember @reyraa covered it in some other ticket. @reyraa could you please confirm.

@slaweet
Copy link
Contributor

slaweet commented Mar 22, 2018

When you are removing the vote dialog autocomplete, you can also remove this as it is not used anywhere else https://github.com/LiskHQ/lisk-hub/blob/75b19d63db0141750da5a62f9f7be8e37fd1c05a/src/utils/api/delegate.js#L23-L41

slaweet
slaweet previously approved these changes Mar 23, 2018
@slaweet slaweet changed the base branch from 0.3.0 to 0.4.0 March 23, 2018 15:03
Copy link
Contributor

@slaweet slaweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, Mike.

@michaeltomasik michaeltomasik merged commit 6617db1 into 0.4.0 Mar 26, 2018
@michaeltomasik michaeltomasik deleted the 535-increase-test-coverage branch March 26, 2018 09:11
faival pushed a commit that referenced this pull request Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants