Skip to content

Commit

Permalink
update to instance-level options
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandrichardson committed Sep 26, 2017
1 parent 88d9c76 commit 9cb6ddb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
8 changes: 7 additions & 1 deletion packages/enzyme-adapter-react-13/src/ReactThirteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ function instanceToTree(inst) {
}

class ReactThirteenAdapter extends EnzymeAdapter {
constructor() {
super();
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true,
};
}
createMountRenderer(options) {
assertDomAvailable('mount');
const domNode = options.attachTo || global.document.createElement('div');
Expand Down Expand Up @@ -144,7 +151,6 @@ class ReactThirteenAdapter extends EnzymeAdapter {
let isDOM = false;
let cachedNode = null;
return {
supportPrevContextArgumentOfComponentDidUpdate: true,
render(el, context) {
cachedNode = el;
/* eslint consistent-return: 0 */
Expand Down
8 changes: 7 additions & 1 deletion packages/enzyme-adapter-react-14/src/ReactFourteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ function instanceToTree(inst) {
}

class ReactFifteenAdapter extends EnzymeAdapter {
constructor() {
super();
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true,
};
}
createMountRenderer(options) {
assertDomAvailable('mount');
const domNode = options.attachTo || global.document.createElement('div');
Expand Down Expand Up @@ -116,7 +123,6 @@ class ReactFifteenAdapter extends EnzymeAdapter {
let isDOM = false;
let cachedNode = null;
return {
supportPrevContextArgumentOfComponentDidUpdate: true,
render(el, context) {
cachedNode = el;
/* eslint consistent-return: 0 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ function instanceToTree(inst) {
}

class ReactFifteenFourAdapter extends EnzymeAdapter {
constructor() {
super();
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true,
};
}
createMountRenderer(options) {
assertDomAvailable('mount');
const domNode = options.attachTo || global.document.createElement('div');
Expand Down Expand Up @@ -146,7 +153,6 @@ class ReactFifteenFourAdapter extends EnzymeAdapter {
let isDOM = false;
let cachedNode = null;
return {
supportPrevContextArgumentOfComponentDidUpdate: true,
render(el, context) {
cachedNode = el;
/* eslint consistent-return: 0 */
Expand Down
8 changes: 7 additions & 1 deletion packages/enzyme-adapter-react-15/src/ReactFifteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ function instanceToTree(inst) {
}

class ReactFifteenAdapter extends EnzymeAdapter {
constructor() {
super();
this.options = {
...this.options,
supportPrevContextArgumentOfComponentDidUpdate: true,
};
}
createMountRenderer(options) {
assertDomAvailable('mount');
const domNode = options.attachTo || global.document.createElement('div');
Expand Down Expand Up @@ -146,7 +153,6 @@ class ReactFifteenAdapter extends EnzymeAdapter {
let isDOM = false;
let cachedNode = null;
return {
supportPrevContextArgumentOfComponentDidUpdate: true,
render(el, context) {
cachedNode = el;
/* eslint consistent-return: 0 */
Expand Down
2 changes: 1 addition & 1 deletion packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class ShallowWrapper {
instance &&
typeof instance.componentDidUpdate === 'function'
) {
if (this[RENDERER].supportPrevContextArgumentOfComponentDidUpdate) {
if (adapter.options.supportPrevContextArgumentOfComponentDidUpdate) {
instance.componentDidUpdate(prevProps, state, prevContext);
} else {
instance.componentDidUpdate(prevProps, state);
Expand Down

0 comments on commit 9cb6ddb

Please sign in to comment.