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

Don't unit test component methods directly #703

Closed
reyraa opened this issue Sep 5, 2017 · 0 comments
Closed

Don't unit test component methods directly #703

reyraa opened this issue Sep 5, 2017 · 0 comments

Comments

@reyraa
Copy link
Contributor

reyraa commented Sep 5, 2017

Expected behaviour

We' moved all the no presentational logics out of our components and just left them with presentational behaviours.
So, preferred is to look at the component as a black box that we won’t penetrate to test. we’ll check its behaviour from outside. so this makes it a unit test in which unit resembles a component as a whole.
an example of such a test is:

it('should allow to change passphrase field to type="text"', () => {
      expect(wrapper.find('.passphrase input').props().type).to.equal('password');
      wrapper.setState({ showPassphrase: true });
      expect(wrapper.find('.passphrase input').props().type).to.equal('text');
});

Actual behaviour

in some cases we test componentDidMount or other specific method directly using notations like:
wrapper.instance().validateUrl

Steps to reproduce

This, this and this are some samples of this kind of tests.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants