-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Viewport: Refactor withViewportMatch to use RTL #44769
Conversation
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.
LGTM 👍 🚀
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import '../store'; | ||
import withViewportMatch from '../with-viewport-match'; | ||
|
||
jest.mock( '@wordpress/compose/src/hooks/use-viewport-match' ); |
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.
Alternatively, maybe we could be able to avoid mocking useViewportMatch
and rather render a useViewportMatch.__experimentalWidthProvider
provider in the tree.
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.
Considering that withViewportMatch
depends on values returned by useViewportMatch
, mocking the hook here makes sense to me.
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.
Yeah, I'm happy with the mock as one of the paths forward, just wanted to mention that there could be an alternative 👍 Feel free to ship as-is (I approved it already)
Size Change: 0 B Total Size: 1.27 MB ℹ️ View Unchanged
|
What?
PR refactors
withViewportMatch
HOC tests to use@testing-library/react
instead ofreact-test-renderer
.Why?
It is a part of recent efforts to use @testing-library/react as the project's primary testing library.
How?
We're just using the
render
method from RTL and improving how assertions are made.Testing Instructions