-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add tests for Modal component #171
Conversation
Thanx man! I’ll check a bit later today 😉 |
<div className={b('inner')}> | ||
<div className={b('title')}> | ||
<div className={b('inner')()}> | ||
<div className={b('title')()}> |
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.
👍
@s4nji looks solid 👍 |
|
||
import Modal from '../../../components/Modal/Modal'; | ||
|
||
configure({ adapter: new Adapter() }); |
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 configure
statement should be inside of a setup file like this one:
https://github.com/hellofresh/my-deliveries-fragment/blob/master/__tests__/setup.js
Also, take a look at this file:
https://github.com/hellofresh/my-deliveries-fragment/blob/master/.jestrc#L2-L5
It contains the instructions to provide a setup file.
}; | ||
const runCommonTest = (wrapper, props) => { | ||
const tree = toJSON(wrapper); | ||
const modaliz = tree.children[0]; |
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.
const [ modaliz ] = tree.children;
configure({ adapter: new Adapter() }); | ||
|
||
describe('Modal component', () => { | ||
const render = props => mount(<Modal {...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.
You can probably pass the requiredProps
directly in this render function, so you don't have to the following over and over again:
const props = {
...requiredProps,
title: 'Modal test title',
};
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 will also need to pass it again in runCommonTest
if we pass it on the render function
I think redefining the props on every test makes it easier to debug since you don't need to search around to find the contents of props
🙂
277f8ae
to
eecd7c5
Compare
eecd7c5
to
0211f0c
Compare
+1 Really well done! |
Adds tests for Modal component