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 Jul 17, 2023
1 parent 5a56a83 commit b3ed681
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 @@ -96,6 +96,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 b3ed681

Please sign in to comment.