-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[core] Use useFormControl instead of withFormControlState #16503
Conversation
testing public interface
Making it more obvious that the full context is private
@@ -105,9 +105,7 @@ describe('<FormControl />', () => { | |||
); | |||
expect(readContext.args[0][0]).to.have.property('focused', false); | |||
|
|||
act(() => { |
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.
unnecessary act
@@ -30,126 +35,141 @@ describe('<FormControlLabel />', () => { | |||
})); | |||
|
|||
it('should render the label text inside an additional element', () => { |
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 test never tested that there is an additional element. Now it does.
@material-ui/core: parsed: +Infinity% , gzip: +Infinity% Details of bundle changes.Comparing: cf2cdd8...d933cd0
|
}); | ||
expect(handleChange.callCount).to.equal(1); | ||
// event.target.check is true | ||
expect(handleChange.firstCall.returnValue).to.be.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.
What's the advantage over using the generic equal?
expect(handleChange.firstCall.returnValue).to.be.true; | |
expect(handleChange.firstCall.returnValue).to.equal(true); |
For reference, I can't find this API equivalent in the Jest documentation: https://jestjs.io/.
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.
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.
@merceyz Thanks for the links. Do you know if there is a .toBeTrue()
like API?
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.
https://jestjs.io/docs/en/expect.html#tobetruthy
That's the closest you'll get
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.
@eps1lon What do you think?
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 not following what the issue is? This appeared to be a question about jest which was answered
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.
My proposal is to replace the usages of to.be.true
and to.be.false
with the generic to.be.equal
API. I have used Jest's API as a benchmark. The opportunity is to reduce the API surface.
FormControlContext.Provider
.