Skip to content

Commit

Permalink
update other 16+ adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
jgzuke committed Aug 17, 2018
1 parent dc9fb23 commit 5d24796
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 6 deletions.
31 changes: 29 additions & 2 deletions packages/enzyme-adapter-react-16.1/src/ReactSixteenOneAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
import { EnzymeAdapter } from 'enzyme';
import {
displayNameOfNode,
elementToTree,
nodeTypeFromType,
elementToTree as utilElementToTree,
nodeTypeFromType as utilNodeTypeFromType,
mapNativeEventNames,
propFromEvent,
assertDomAvailable,
Expand Down Expand Up @@ -72,6 +72,33 @@ function flatten(arr) {
return result;
}

function nodeTypeFromType(type) {
if (type && type === Portal) {
return 'portal';
}

return utilNodeTypeFromType(type);
}

function elementToTree(el) {
if (!(el && el.$$typeof === Portal)) {
return utilElementToTree(el, elementToTree);
}

const { children, containerInfo } = el;
const props = { children, containerInfo };

return {
nodeType: 'portal',
type: Portal,
props,
key: ensureKeyOrUndefined(el.key),
ref: el.ref,
instance: null,
rendered: elementToTree(el.children),
};
}

function toTree(vnode) {
if (vnode == null) {
return null;
Expand Down
31 changes: 29 additions & 2 deletions packages/enzyme-adapter-react-16.2/src/ReactSixteenTwoAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { EnzymeAdapter } from 'enzyme';
import { typeOfNode } from 'enzyme/build/Utils';
import {
displayNameOfNode,
elementToTree,
nodeTypeFromType,
elementToTree as utilElementToTree,
nodeTypeFromType as utilNodeTypeFromType,
mapNativeEventNames,
propFromEvent,
assertDomAvailable,
Expand Down Expand Up @@ -73,6 +73,33 @@ function flatten(arr) {
return result;
}

function nodeTypeFromType(type) {
if (type && type === Portal) {
return 'portal';
}

return utilNodeTypeFromType(type);
}

function elementToTree(el) {
if (!(el && el.$$typeof === Portal)) {
return utilElementToTree(el, elementToTree);
}

const { children, containerInfo } = el;
const props = { children, containerInfo };

return {
nodeType: 'portal',
type: Portal,
props,
key: ensureKeyOrUndefined(el.key),
ref: el.ref,
instance: null,
rendered: elementToTree(el.children),
};
}

function toTree(vnode) {
if (vnode == null) {
return null;
Expand Down
31 changes: 29 additions & 2 deletions packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { EnzymeAdapter } from 'enzyme';
import { typeOfNode } from 'enzyme/build/Utils';
import {
displayNameOfNode,
elementToTree,
nodeTypeFromType,
elementToTree as utilElementToTree,
nodeTypeFromType as utilNodeTypeFromType,
mapNativeEventNames,
propFromEvent,
assertDomAvailable,
Expand Down Expand Up @@ -78,6 +78,33 @@ function flatten(arr) {
return result;
}

function nodeTypeFromType(type) {
if (type && type === Portal) {
return 'portal';
}

return utilNodeTypeFromType(type);
}

function elementToTree(el) {
if (!(el && el.$$typeof === Portal)) {
return utilElementToTree(el, elementToTree);
}

const { children, containerInfo } = el;
const props = { children, containerInfo };

return {
nodeType: 'portal',
type: Portal,
props,
key: ensureKeyOrUndefined(el.key),
ref: el.ref,
instance: null,
rendered: elementToTree(el.children),
};
}

function toTree(vnode) {
if (vnode == null) {
return null;
Expand Down

0 comments on commit 5d24796

Please sign in to comment.