Conversation
let wrapper; | ||
|
||
beforeEach(() => { | ||
props = { |
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.
there is an issue with react-dropzone that is generating an error:
react-dropzone/react-dropzone#554
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.
updated
it('should render to right', () => { | ||
wrapper.setProps({ menuOffsetDirection: 'right' }); | ||
expect(wrapper.find('.menu').prop('style')).toHaveProperty('left', -30); | ||
expect(wrapper.find('.menu').prop('style')).toHaveProperty('right', undefined); |
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.
these two expect expressions could be merged into one like in this example:
expect(wrapper.find('.video-stream img').prop('style')).toEqual({width: 600,height:450})
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.
As we discussed, this would not be a good idea in this case.
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.
There is a recommendation to use .toBeUndefined() when checking for undefined.
https://jestjs.io/docs/en/expect#tobeundefined
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.
updated
it('should not propagate click', () => { | ||
wrapper.simulate('click', mockClickEvent); | ||
expect(mockClickEvent.stopPropagation).toBeCalled(); | ||
}); | ||
}); |
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.
We agreed on the following:
-Use .toHaveLength() to check for element existence, because it also checks if it exists only once.
-In the future, use .hasClass() where applicable. It's not worth the effort to rewrite anything for this now.
-Use .prop('disabled') to check for disabled status, instead of .find([disabled])
-Use toBe() when not comparing objects.
-Use .prop('key') instead of .props().key.
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.
updated
it('should call onSubmitHandler when form is submitted', () => { | ||
wrapper.simulate('submit', mockClickEvent); | ||
expect(props.onSubmitHandler).toHaveBeenCalled(); | ||
expect(wrapper.state().submitted).toEqual(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.
I propose to use state() as we agreed in the case of props().
state('key') instead of state().key
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.
updated
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { UnmountClosed } from 'react-collapse'; |
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 import should be a few lines below in the component list.
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 normally put external imports at the top, then our components under // components
. react-collapse is an external import.
wrapper.find('.label').simulate('click', mockClickEvent); | ||
expect(wrapper.find('.visible')).toHaveLength(1); | ||
wrapper.find('.label').simulate('click', mockClickEvent); | ||
expect(wrapper.find('.visible').exists()).toEqual(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.
What is the reason here for having 2 different patterns to check for the existence of an element with this class?
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.
It's not, the first checks that it's open, the the second checks that it's closed
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.
Please take a look at the comments.
Everything looks good. |
No description provided.