Skip to content

Commit

Permalink
[enzyme-adapter-react-*] [new] add legacyContextMode, and `getChild…
Browse files Browse the repository at this point in the history
…Context` lifecycle method
  • Loading branch information
minznerjosh authored and ljharb committed Jan 7, 2019
1 parent db090c6 commit 3ecf054
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class ReactThirteenAdapter extends EnzymeAdapter {
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true, // TODO: remove, semver-major
legacyContextMode: 'owner',
lifecycles: {
...lifecycles,
componentDidUpdate: {
Expand Down
4 changes: 4 additions & 0 deletions packages/enzyme-adapter-react-14/src/ReactFourteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ class ReactFourteenAdapter extends EnzymeAdapter {
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
prevContext: true,
},
getChildContext: {
calledByRenderer: true,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ class ReactFifteenFourAdapter extends EnzymeAdapter {
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
prevContext: true,
},
getChildContext: {
calledByRenderer: true,
},
},
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/enzyme-adapter-react-15/src/ReactFifteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ class ReactFifteenAdapter extends EnzymeAdapter {
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
prevContext: true,
},
getChildContext: {
calledByRenderer: true,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class ReactSixteenOneAdapter extends EnzymeAdapter {
const { lifecycles } = this.options;
this.options = {
...this.options,
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
Expand All @@ -242,6 +243,9 @@ class ReactSixteenOneAdapter extends EnzymeAdapter {
setState: {
skipsComponentDidUpdateOnNullish: true,
},
getChildContext: {
calledByRenderer: false,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ class ReactSixteenTwoAdapter extends EnzymeAdapter {
this.options = {
...this.options,
enableComponentDidUpdateOnSetState: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
Expand All @@ -244,6 +245,9 @@ class ReactSixteenTwoAdapter extends EnzymeAdapter {
setState: {
skipsComponentDidUpdateOnNullish: true,
},
getChildContext: {
calledByRenderer: false,
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class ReactSixteenThreeAdapter extends EnzymeAdapter {
this.options = {
...this.options,
enableComponentDidUpdateOnSetState: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
Expand All @@ -247,6 +248,9 @@ class ReactSixteenThreeAdapter extends EnzymeAdapter {
setState: {
skipsComponentDidUpdateOnNullish: true,
},
getChildContext: {
calledByRenderer: false,
},
},
};
}
Expand Down
4 changes: 4 additions & 0 deletions packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ class ReactSixteenAdapter extends EnzymeAdapter {
this.options = {
...this.options,
enableComponentDidUpdateOnSetState: true, // TODO: remove, semver-major
legacyContextMode: 'parent',
lifecycles: {
...lifecycles,
componentDidUpdate: {
Expand All @@ -267,6 +268,9 @@ class ReactSixteenAdapter extends EnzymeAdapter {
setState: {
skipsComponentDidUpdateOnNullish: true,
},
getChildContext: {
calledByRenderer: false,
},
},
};
}
Expand Down

0 comments on commit 3ecf054

Please sign in to comment.