Skip to content

Commit

Permalink
Revert "[New] shallow: Add invoke(eventName, ...args)"
Browse files Browse the repository at this point in the history
This reverts commit eb14926cbc5de867745ca7c892bda533ddff043b.
  • Loading branch information
ljharb committed Apr 6, 2019
1 parent 258823f commit 60ea652
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 294 deletions.
1 change: 0 additions & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
* [hasClass(className)](/docs/api/ShallowWrapper/hasClass.md)
* [hostNodes()](/docs/api/ShallowWrapper/hostNodes.md)
* [html()](/docs/api/ShallowWrapper/html.md)
* [invoke(event[, ...args])](/docs/api/ShallowWrapper/invoke.md)
* [instance()](/docs/api/ShallowWrapper/instance.md)
* [is(selector)](/docs/api/ShallowWrapper/is.md)
* [isEmpty()](/docs/api/ShallowWrapper/isEmpty.md)
Expand Down
39 changes: 0 additions & 39 deletions docs/api/ShallowWrapper/invoke.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/api/shallow.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,6 @@ Returns the key of the current node.
#### [`.simulate(event[, data]) => ShallowWrapper`](ShallowWrapper/simulate.md)
Simulates an event on the current node.

#### [`.invoke(event[, ...args]) => Any`](ShallowWrapper/invoke.md)
Invokes an event handler on the current node and returns the handlers value.

#### [`.setState(nextState) => ShallowWrapper`](ShallowWrapper/setState.md)
Manually sets state of the root component.

Expand Down
1 change: 0 additions & 1 deletion packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,6 @@ describe('shallow', () => {
'hostNodes',
'html',
'instance',
'invoke',
'is',
'isEmpty',
'isEmptyRender',
Expand Down
224 changes: 0 additions & 224 deletions packages/enzyme-test-suite/test/shared/methods/invoke.jsx

This file was deleted.

26 changes: 0 additions & 26 deletions packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,32 +1106,6 @@ class ShallowWrapper {
return this.type() === null ? cheerio() : cheerio.load('')(this.html());
}

/*
* Used to simulate events. Pass an eventname and (optionally) event arguments.
* Will invoke an event handler prop of the same name and return its value.
*
* @param {String} event
* @param {Array} args
* @returns {Any}
*/
invoke(event, ...args) {
return this.single('invoke', () => {
const handler = this.prop(propFromEvent(event));
let response = null;

if (handler) {
withSetStateAllowed(() => {
performBatchedUpdates(this, () => {
response = handler(...args);
});
this.root.update();
});
}

return response;
});
}

/**
* Used to simulate events. Pass an eventname and (optionally) event arguments. This method of
* testing events should be met with some skepticism.
Expand Down

0 comments on commit 60ea652

Please sign in to comment.