-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
test(factories): add factory tests #552
Conversation
267dc85
to
d2180ca
Compare
Current coverage is 100% (diff: 100%)
|
d2180ca
to
4b60626
Compare
@@ -16,7 +16,7 @@ const mergePropsAndClassName = (defaultProps, props) => { | |||
newProps.className = cx(defaultProps.className, props.className) // eslint-disable-line react/prop-types | |||
} | |||
|
|||
if (!newProps.key) { | |||
if (!newProps.key && childKey) { |
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.
Prevent adding childKey: undefined
due to props with no key and also not defining a childKey
. This issue was revealed by tests.
4b60626
to
908ec25
Compare
Just force pushed |
itReturnsNullGivenDefaultPropsFunc(null) | ||
}) | ||
|
||
describe('from 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.
Add similar tests for booleans. Both true
and false
should return null
}) | ||
} | ||
|
||
const itMergesClassNames = (extraClassName, classNameSource, shorthandConfig) => { |
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.
Put classNameSource
as first arg:
- matches
propsSource
being first in the functions below - currently args 1 and 3 are used in the test and 2 is used to describe the test which is a little confusing.
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.
Left a few suggestions but looks good otherwise so I'm approving 👍
908ec25
to
3e0d6c6
Compare
Thanks much, updated both suggestions. Will merge on pass. |
This PR adds tests for
createShorthand
, it does not add tests for every shorthand factory, however, they are partially applied so it is almost redundant.