-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Fix jest-emotion for preact #731
Fix jest-emotion for preact #731
Conversation
Could u add a test for this? |
Probably not easily. I don’t have time to do it right now. I mentioned this in the PR |
eaa372a
to
42a7de0
Compare
@Andarist just added a test. |
|
||
it('replaces class names and inserts styles into preact test component snapshots', () => { | ||
const tree = render( | ||
<div class={divStyle}> |
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.
is preact
accepting class
instead of className
?
There is a linting problem found in this file:
Unknown property 'class' found, use 'className' instead react/no-unknown-property
If class
is correct in preact
you can just disable this rule for this file (with top file comment or smth)
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.
Thanks. Fixed. And yes, preact
takes all the html style instead of js style (class
and for
, for example)
42a7de0
to
db6fddf
Compare
packages/jest-emotion/src/utils.js
Outdated
@@ -6,7 +6,7 @@ function getClassNames(selectors, classes) { | |||
|
|||
function getClassNamesFromTestRenderer(selectors, node) { | |||
const props = node.props | |||
return getClassNames(selectors, props.className || props.class) | |||
return props ? getClassNames(selectors, props.className || props.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.
I think it should be : selectors
instead of : []
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.
Nice catch, fixed.
Apparently preact doesn't always give props, so we need to deal with that.
78ff276
to
0a7c65d
Compare
Thanks for the PR @aaronjensen |
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.
Thanks!!
What:
Preact, when rendered by preact-render-to-json does not always have props, so we
need to account for this.
Why:
So it works.
How:
Assume no classes if there are no props.
Checklist: