-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add support for passing context to React class based components via contextType #2507
base: master
Are you sure you want to change the base?
Conversation
Add support for passing context to React class based components that request context via setting .contextType, according to patches posted in enzymejs#2189 (comment). Adds changes to ReactSixteenAdapter and simple test case. Co-authored-by: Kevin Read <[email protected]> Co-authored-by: Pablo Palacios <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #2507 +/- ##
===========================================
- Coverage 96.31% 71.97% -24.35%
===========================================
Files 49 49
Lines 4207 4210 +3
Branches 1130 1132 +2
===========================================
- Hits 4052 3030 -1022
- Misses 155 1180 +1025
Continue to review full report at Codecov.
|
Hmm, the new unit tests are failing, but they're working locally here. I'll try to reproduce this with the respective build configurations |
My bad. The tests are expected to fail because they use the unpatched react-shallow-renderer :) |
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.
Could we also add a test that changes the provided value, and ensures that the new value also shows up?
it('works on a Provider', () => { | ||
const wrapper = shallow(<OuterComponent />); | ||
const provides = wrapper.find(Provider).dive(); | ||
const provider = provides.find(InnerComponent).shallow(); |
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.
const provider = provides.find(InnerComponent).shallow(); | |
const provider = provides.find(InnerComponent).dive(); |
any reason this wouldn't work?
This comment was marked as outdated.
This comment was marked as outdated.
43eb75e
to
39e6b1f
Compare
16cf05f
to
658422b
Compare
Based on the patches posted in #2189 (comment) by @forivall (thanks!).
Adds changes to ReactSixteenAdapter and simple test case.