Add support for passing context to React class based components via contextType#2507
Add support for passing context to React class based components via contextType#2507unverbraucht wants to merge 1 commit intoenzymejs:masterfrom
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 <me@kevin-read.com> Co-authored-by: Pablo Palacios <pablo.palacios@holidaycheck.com>
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 :) |
ljharb
left a comment
There was a problem hiding this comment.
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.
| 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.