Skip to content

Commit b3ed681

Browse files
committed
added test for empty lazy component
1 parent 5a56a83 commit b3ed681

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

compat/test/browser/suspense-hydration.test.js

+31
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,37 @@ describe('suspense hydration', () => {
9696
});
9797
});
9898

99+
it('should correct processed empty result of lazy component', () => {
100+
scratch.innerHTML = '<main><p>i am not from lazy</p></main>';
101+
clearLog();
102+
103+
const [Lazy, resolve] = createLazy();
104+
hydrate(
105+
<main>
106+
<Suspense fallback={<p>will be never showed while hydration</p>}>
107+
<Lazy />
108+
</Suspense>
109+
<p>i am not from lazy</p>
110+
</main>,
111+
scratch
112+
);
113+
rerender(); // Flush rerender queue to mimic what preact will really do
114+
expect(scratch.innerHTML).to.equal(
115+
'<main><p>i am not from lazy</p></main>'
116+
);
117+
expect(getLog()).to.deep.equal([]);
118+
clearLog();
119+
120+
return resolve(() => null).then(() => {
121+
rerender();
122+
expect(scratch.innerHTML).to.equal(
123+
'<main><p>i am not from lazy</p></main>'
124+
);
125+
expect(getLog()).to.deep.equal([]);
126+
clearLog();
127+
});
128+
});
129+
99130
it('should properly attach event listeners when suspending while hydrating', () => {
100131
scratch.innerHTML = '<div>Hello</div><div>World</div>';
101132
clearLog();

0 commit comments

Comments
 (0)