-
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
Interface: Refactor FullscreenMode component tests to use RTL #44803
Conversation
Size Change: +340 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
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 work 👍 Left a few optional suggestions, but regardless it already looks good 🚀
packages/interface/src/components/fullscreen-mode/test/index.js
Outdated
Show resolved
Hide resolved
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe( | ||
true | ||
); | ||
const { baseElement } = render( <FullscreenMode isActive={ true } /> ); |
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.
Good call to use baseElement
👍
); | ||
|
||
unmount(); |
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.
Instead of calling unmount
, does it make sense to just rerender()
some <div />
so the original component is no longer in the component tree, which will ultimately trigger an unmount?
Since this is part of the API it could be the most explicit way to express what we're aiming to test, though, so feel free to keep it as-is.
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.
The unmount
makes sense to me when testing effect cleanup.
packages/interface/src/components/fullscreen-mode/test/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Marin Atanasov <[email protected]>
Co-authored-by: Marin Atanasov <[email protected]>
What?
PR of #44780.
PR refactors
FullscreenMode
component 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, improving how assertions.
Testing Instructions