Skip to content

Commit

Permalink
[enzyme-adapter-react-16] [fix] isMemo and isLazy are no longer d…
Browse files Browse the repository at this point in the history
…irectly useful for us as of `react-is` `v16.12`
  • Loading branch information
lh0x00 authored and ljharb committed Nov 30, 2019
1 parent f327891 commit dba05db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
isContextProvider,
isElement,
isForwardRef,
isLazy,
isMemo,
isPortal,
isSuspense,
isValidElementType,
Expand Down Expand Up @@ -58,6 +56,7 @@ import {
getNodeFromRootFinder,
wrapWithWrappingComponent,
getWrappingComponentMountRenderer,
compareNodeTypeOf,
} from 'enzyme-adapter-utils';
import findCurrentFiberUsingSlowPath from './findCurrentFiberUsingSlowPath';
import detectFiberTags from './detectFiberTags';
Expand Down Expand Up @@ -109,6 +108,14 @@ function nodeTypeFromType(type) {
return utilNodeTypeFromType(type);
}

function isMemo(type) {
return compareNodeTypeOf(type, Memo);
}

function isLazy(type) {
return compareNodeTypeOf(type, Lazy);
}

function unmemoType(type) {
return isMemo(type) ? type.type : type;
}
Expand Down
8 changes: 6 additions & 2 deletions packages/enzyme-test-suite/test/Adapter-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import inspect from 'object-inspect';
import {
Portal,
Memo,
isMemo,
} from 'react-is';
import PropTypes from 'prop-types';
import wrap from 'mocha-wrap';
Expand All @@ -29,7 +28,12 @@ import {
Suspense,
} from './_helpers/react-compat';
import { is } from './_helpers/version';
import { itIf, describeWithDOM, describeIf } from './_helpers';
import {
itIf,
describeWithDOM,
describeIf,
isMemo,
} from './_helpers';

const { adapter } = get();

Expand Down
7 changes: 7 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* globals jsdom */

import React from 'react';
import { Memo } from 'react-is';
import { compareNodeTypeOf } from 'enzyme-adapter-utils';


/**
* Simple wrapper around mocha describe which allows a boolean to be passed in first which
Expand Down Expand Up @@ -158,3 +161,7 @@ export function delay(ms) {
setTimeout(resolve, ms);
});
}

export function isMemo(type) {
return compareNodeTypeOf(type, Memo);
}

0 comments on commit dba05db

Please sign in to comment.