Skip to content

Commit

Permalink
[Fix] shallow/mount: matchesElement/containsMatchingElement: …
Browse files Browse the repository at this point in the history
…get adapter with options
  • Loading branch information
ljharb committed Jul 19, 2018
1 parent 6767ce5 commit e954e46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ class ReactWrapper {
*/
matchesElement(node) {
return this.single('matchesElement', () => {
const rstNode = getAdapter().elementToNode(node);
const adapter = getAdapter(this[OPTIONS]);
const rstNode = adapter.elementToNode(node);
return nodeMatches(rstNode, this.getNodeInternal(), (a, b) => a <= b);
});
}
Expand Down
6 changes: 4 additions & 2 deletions packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ class ShallowWrapper {
* @returns {Boolean}
*/
containsMatchingElement(node) {
const rstNode = getAdapter().elementToNode(node);
const adapter = getAdapter(this[OPTIONS]);
const rstNode = adapter.elementToNode(node);
const predicate = other => nodeMatches(rstNode, other, (a, b) => a <= b);
return findWhereUnwrapped(this, predicate).length > 0;
}
Expand Down Expand Up @@ -623,7 +624,8 @@ class ShallowWrapper {
*/
matchesElement(node) {
return this.single('matchesElement', () => {
const rstNode = getAdapter().elementToNode(node);
const adapter = getAdapter(this[OPTIONS]);
const rstNode = adapter.elementToNode(node);
return nodeMatches(rstNode, this.getNodeInternal(), (a, b) => a <= b);
});
}
Expand Down

0 comments on commit e954e46

Please sign in to comment.