Skip to content

Commit

Permalink
Add additional type checks to adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense authored and ljharb committed Jul 2, 2018
1 parent aeef090 commit 12dc650
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/enzyme/src/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ export function typeOfNode(node) {

export function nodeHasType(node, type) {
if (!type || !node) return false;

const adapter = getAdapter();
if (adapter.displayNameOfNode) {
const displayName = adapter.displayNameOfNode(node);
if (displayName === type) return true;
}

if (!node.type) return false;
if (typeof node.type === 'string') return node.type === type;
return (
Expand Down Expand Up @@ -235,6 +242,7 @@ export function AND(fns) {
return x => fnsReversed.every(fn => fn(x));
}

// TODO: semver-major: remove
export function displayNameOfNode(node) {
if (!node) return null;

Expand Down

0 comments on commit 12dc650

Please sign in to comment.