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 c210eca commit c45bf1a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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
4 changes: 3 additions & 1 deletion packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,8 @@ describeWithDOM('mount', () => {
);
}
}
it('finds Suspense and its children when no lazy component', () => {

it.only('finds Suspense and its children when no lazy component', () => {
class Component extends React.Component {
render() {
return (
Expand All @@ -1129,6 +1130,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 c45bf1a

Please sign in to comment.