Skip to content

Commit

Permalink
add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jul 18, 2024
1 parent f74d6cd commit b03cb78
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions compat/test/browser/suspense-hydration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,38 @@ describe('suspense hydration', () => {
});
});

it('Should hydrate a fragment with no children correctly', () => {
scratch.innerHTML = '<!--$s--><!--/$s--><div>Hello world</div>';
clearLog();

const [Lazy, resolve] = createLazy();
hydrate(
<>
<Suspense>
<Lazy />
</Suspense>
<div>Hello world</div>
</>,
scratch
);
rerender(); // Flush rerender queue to mimic what preact will really do
expect(scratch.innerHTML).to.equal(
'<!--$s--><!--/$s--><div>Hello world</div>'
);
expect(getLog()).to.deep.equal([]);
clearLog();

return resolve(() => null).then(() => {
rerender();
expect(scratch.innerHTML).to.equal(
'<!--$s--><!--/$s--><div>Hello world</div>'
);
expect(getLog()).to.deep.equal([]);

clearLog();
});
});

it('should leave DOM untouched when suspending while hydrating', () => {
scratch.innerHTML = '<!-- test --><div>Hello</div>';
clearLog();
Expand Down

0 comments on commit b03cb78

Please sign in to comment.