-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[InputBase] Improve documentation for custom inputComponent
#16399
Conversation
const wrapper = mount(<InputBase inputComponent={BadInputComponent} />); | ||
assert.throws( | ||
// simulating e.g. react-stripe-elements that hides the event target | ||
() => wrapper.find('input').simulate('change', { target: null }), |
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.
aside: no idea why this simulate is StrictMode compatible but fireEvent.change
doesn't even register. Probably missing something obvious about change
events.
@material-ui/core: parsed: +0.07% , gzip: +0.15% Details of bundle changes.Comparing: a1ffac5...c22a2a3
|
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 :)
Did some testing before this PR and it was not useful to minify the error messages. Might be at some point though. Should keep an eye on it. |
import { expect } from 'chai'; | ||
import { getContents } from './parseMarkdown'; | ||
|
||
describe('parseMarkdown', () => { |
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 is the kind of test where I would prefer fixtures + snapshots but it's not worth it to set this up for one test. If this test becomes an issue (breaks, readability etc) we can revisit.
@@ -37,7 +37,7 @@ export const demoRegexp = /^"demo": "(.*)"/; | |||
export function getContents(markdown) { | |||
return markdown | |||
.replace(headerRegExp, '') // Remove header information | |||
.split(/^{{|}}$/gm) // Split markdown into an array, separating demos | |||
.split(/^{{("demo":[^}]*)}}$/gm) // Split markdown into an array, separating demos |
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'm so tired of browser tests. Icing this until this is important. |
}} can come from code formatting of JSX attributes
286a4d2
to
b32cde3
Compare
); | ||
let errorMessage = null; | ||
try { | ||
handleRef.current.trigger(); |
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.
fireEvent.change needs a non-null value to trigger the handler.
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.
Right. That was the part I was missing about change events. Got a simpler idea though which is closer to how react-stripe-elements works.
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 issue was less about how change events are created but rather about error handling in react. I'm unable to catch errors from event handlers in our browser tests.
b32cde3
to
e4eb9c4
Compare
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.
Great :)
Closes #16037
Turns out we already document it but are not very explicit about it.