-
-
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
Add toHaveStyleRule to jest-emotion #662
Add toHaveStyleRule to jest-emotion #662
Conversation
// This could be done in a more efficient way | ||
// but it would be a breaking change to do so | ||
// because it would change the ordering of styles | ||
Object.keys(emotion.caches.registered).forEach(className => { |
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.
personally I would replace forEach
with reduce
here
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 actually copied that block of code from index.js because it did what I needed. Agree it should be refactored 👍
packages/jest-emotion/src/index.js
Outdated
@@ -37,12 +39,14 @@ function getClassNamesFromDOMElement(selectors, node) { | |||
return getClassNames(selectors, node.getAttribute('class')) | |||
} | |||
|
|||
function getClassNamesFromNodes(nodes) { | |||
export function getClassNamesFromNodes(nodes) { |
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.
Could you move this into a utils file and import it from that file because exporting from here means it’s exported from the main package so people could start using it and if we wanted to change it we would have to do a major version
Codecov Report
|
It should be code complete now, I'll see what I can do about increasing the code coverage though. I'm not sure how to add a new dependency to a package. I tried |
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!!
Thanks! |
Hey guys! Great that this feature is finally merged to master, really looking forward to using it! |
We hope to make a new release this week, can't promise anything though. |
What:
Feature: adding
toHaveStyleRule
tojest-emotion
.Why:
This utility is provided by
jest-styled-components
andjest-glamor-react
, so is a blocker for people wanting to port toemotion
. Already tracked here: #645How:
I originally wrote the utility for
jest-glamor-react
and that was in turn based on the same utility injest-styled-components
.Checklist: