Skip to content

Commit 00ff574

Browse files
committed
added test for empty lazy component
1 parent b5bdcef commit 00ff574

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,37 @@ describe('suspense hydration', () => {
121121
});
122122
});
123123

124+
it('should correct processed empty result of lazy component', () => {
125+
scratch.innerHTML = '<main><p>i am not from lazy</p></main>';
126+
clearLog();
127+
128+
const [Lazy, resolve] = createLazy();
129+
hydrate(
130+
<main>
131+
<Suspense fallback={<p>will be never showed while hydration</p>}>
132+
<Lazy />
133+
</Suspense>
134+
<p>i am not from lazy</p>
135+
</main>,
136+
scratch
137+
);
138+
rerender(); // Flush rerender queue to mimic what preact will really do
139+
expect(scratch.innerHTML).to.equal(
140+
'<main><p>i am not from lazy</p></main>'
141+
);
142+
expect(getLog()).to.deep.equal([]);
143+
clearLog();
144+
145+
return resolve(() => null).then(() => {
146+
rerender();
147+
expect(scratch.innerHTML).to.equal(
148+
'<main><p>i am not from lazy</p></main>'
149+
);
150+
expect(getLog()).to.deep.equal([]);
151+
clearLog();
152+
});
153+
});
154+
124155
it('should properly attach event listeners when suspending while hydrating', () => {
125156
scratch.innerHTML = '<div>Hello</div><div>World</div>';
126157
clearLog();

0 commit comments

Comments
 (0)