Skip to content

Commit

Permalink
offscreencomponent wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 26, 2020
1 parent c6c9150 commit 8a6075b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-17/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"object.values": "^1.1.1",
"prop-types": "^15.7.2",
"react-is": "^17.0.0",
"react-reconciler": "^0.26.1",
"react-test-renderer": "^17.0.0",
"semver": "^5.7.0"
},
Expand Down
12 changes: 12 additions & 0 deletions packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ function toTree(vnode) {
}
case FiberTags.Lazy:
return childrenToTree(node.child);
case FiberTags.OffscreenComponent: {
console.log(node.return.memoizedProps.children);
return {
nodeType: 'function',
type: Suspense,
props: { ...node.memoizedProps },
key: ensureKeyOrUndefined(node.key),
ref: node.ref,
instance: null,
rendered: childrenToTree(nodeToHostNode(node.return.memoizedProps.children)),
};
}
default:
throw new Error(`Enzyme Internal Error: unknown node with tag ${node.tag}`);
}
Expand Down
1 change: 1 addition & 0 deletions packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,7 @@ describeWithDOM('mount', () => {
const wrapper = mount(<SuspenseComponent />);

expect(wrapper.is(SuspenseComponent)).to.equal(true);
console.log(wrapper.debug());
expect(wrapper.find(Component)).to.have.lengthOf(1);
expect(wrapper.find(Fallback)).to.have.lengthOf(0);
});
Expand Down

0 comments on commit 8a6075b

Please sign in to comment.