Skip to content

Commit

Permalink
[fix] mount: invoke: use adapter’s wrapInvoke if present
Browse files Browse the repository at this point in the history
  • Loading branch information
chenesan authored and ljharb committed Jun 9, 2019
1 parent 2a862c7 commit d2bb655
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/api/ReactWrapper/invoke.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# `.invoke(propName)(...args) => Any`

Invokes a function prop.
Note that in React 16.8+, `.invoke` will wrap your handler with [`ReactTestUtils.act`](https://reactjs.org/docs/test-utils.html#act) and call `.update()` automatically.

#### Arguments

Expand Down
4 changes: 3 additions & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,9 @@ class ReactWrapper {
throw new TypeError('ReactWrapper::invoke() requires the name of a prop whose value is a function');
}
return (...args) => {
const response = handler(...args);
const response = typeof this[RENDERER].wrapInvoke === 'function'
? this[RENDERER].wrapInvoke(() => handler(...args))
: handler(...args);
this[ROOT].update();
return response;
};
Expand Down

0 comments on commit d2bb655

Please sign in to comment.