-
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
URLInput test: use valid url value to pass through validation #47444
Conversation
Size Change: -24.6 kB (-2%) Total Size: 1.31 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.
Looks great, thanks @jsnajdr 👍
function TestInputButton() { | ||
const [ url, onChange ] = useState( '' ); | ||
return <URLInputButton url={ url } onChange={ onChange } />; | ||
} |
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's worth adding a comment explaining why we're adding the wrapper component. It might be unclear to someone looking at the test without context.
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.
Comment added 👍
Fixes one
URLInput
unit test that starts failing after Jest upgrade (WIP in #47388), namely after upgrade of the bundled JSDOM (from 16.0 to 20.0).The "should close the form when user submits it" test is rendering a controlled
<URLInputButton>
component without aurl
value prop, and then types something into that component's<input>
field. But because there's no value, theinput
's value doesn't really change. It remains empty.The
URLInputButton
renders a form that's like:and our test clicks the "submit" button. However, JSDOM implemented form validation in v18, and because the
required
input is empty, it won't submit the form.This PR fixes the test by rendering a helper component that maintains the input state.