Skip to content

Commit c45bf1a

Browse files
committed
offscreencomponent wip
1 parent c210eca commit c45bf1a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

packages/enzyme-adapter-react-17/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"object.values": "^1.1.1",
4646
"prop-types": "^15.7.2",
4747
"react-is": "^17.0.0",
48+
"react-reconciler": "^0.26.1",
4849
"react-test-renderer": "^17.0.0",
4950
"semver": "^5.7.0"
5051
},

packages/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,18 @@ function toTree(vnode) {
298298
}
299299
case FiberTags.Lazy:
300300
return childrenToTree(node.child);
301+
case FiberTags.OffscreenComponent: {
302+
console.log(node.return.memoizedProps.children);
303+
return {
304+
nodeType: 'function',
305+
type: Suspense,
306+
props: { ...node.memoizedProps },
307+
key: ensureKeyOrUndefined(node.key),
308+
ref: node.ref,
309+
instance: null,
310+
rendered: childrenToTree(nodeToHostNode(node.return.memoizedProps.children)),
311+
};
312+
}
301313
default:
302314
throw new Error(`Enzyme Internal Error: unknown node with tag ${node.tag}`);
303315
}

packages/enzyme-test-suite/test/ReactWrapper-spec.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,8 @@ describeWithDOM('mount', () => {
11111111
);
11121112
}
11131113
}
1114-
it('finds Suspense and its children when no lazy component', () => {
1114+
1115+
it.only('finds Suspense and its children when no lazy component', () => {
11151116
class Component extends React.Component {
11161117
render() {
11171118
return (
@@ -1129,6 +1130,7 @@ describeWithDOM('mount', () => {
11291130
const wrapper = mount(<SuspenseComponent />);
11301131

11311132
expect(wrapper.is(SuspenseComponent)).to.equal(true);
1133+
console.log(wrapper.debug());
11321134
expect(wrapper.find(Component)).to.have.lengthOf(1);
11331135
expect(wrapper.find(Fallback)).to.have.lengthOf(0);
11341136
});

0 commit comments

Comments
 (0)