-
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
Edit Post: Refactor PageAttributesOrder
tests to @testing-library/react
#43980
Conversation
Size Change: +142 B (0%) Total Size: 1.25 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.
This works well in my tests.
I will leave the final decision about #43980 (comment) to you, @ciampo and @mirka.
/** | ||
* When starting to type inside the spinbutton, select the current value | ||
* in order to override it with the new value afterwards. | ||
*/ | ||
const typeOptions = { | ||
initialSelectionStart: 0, | ||
initialSelectionEnd: 1, | ||
}; |
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 know I'm late, but wouldn't this only the first character in the input's value, instead of the whole value?
A good alternative could be to use the clear
utility
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 did try .clear()
but didn't like the end result, because it was adding additional invocations of the mocks, while this approach kept them the same as the original.
What?
We've recently started refactoring
enzyme
tests to@testing-library/react
.This PR refactors the
<PageAttributesOrder />
component tests fromenzyme
to@testing-library/react
.Why?
@testing-library/react
provides a better way to write tests for accessible components that is closer to the way the user experiences them.How?
We're straightforwardly replacing
enzyme
tests with@testing-library/react
ones, usingjest-dom
matchers and mocks to avoid testing unrelated implementation details.Testing Instructions
Verify tests pass:
npm run test:unit packages/editor/src/components/page-attributes/test/order.js