Skip to content

Commit

Permalink
added test for empty lazy component
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandrjet committed Oct 8, 2024
1 parent b5bdcef commit 00ff574
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions compat/test/browser/suspense-hydration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ describe('suspense hydration', () => {
});
});

it('should correct processed empty result of lazy component', () => {
scratch.innerHTML = '<main><p>i am not from lazy</p></main>';
clearLog();

const [Lazy, resolve] = createLazy();
hydrate(
<main>
<Suspense fallback={<p>will be never showed while hydration</p>}>
<Lazy />
</Suspense>
<p>i am not from lazy</p>
</main>,
scratch
);
rerender(); // Flush rerender queue to mimic what preact will really do
expect(scratch.innerHTML).to.equal(
'<main><p>i am not from lazy</p></main>'
);
expect(getLog()).to.deep.equal([]);
clearLog();

return resolve(() => null).then(() => {
rerender();
expect(scratch.innerHTML).to.equal(
'<main><p>i am not from lazy</p></main>'
);
expect(getLog()).to.deep.equal([]);
clearLog();
});
});

it('should properly attach event listeners when suspending while hydrating', () => {
scratch.innerHTML = '<div>Hello</div><div>World</div>';
clearLog();
Expand Down

0 comments on commit 00ff574

Please sign in to comment.