Skip to content

Commit

Permalink
add failing test for three suspended direct children withing a suspen…
Browse files Browse the repository at this point in the history
…se boundary that resolve one-after-another
  • Loading branch information
f0x52 committed Jan 16, 2025
1 parent 81e7da3 commit 24dbf7c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/compat/async.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,48 @@ describe('Async renderToString', () => {
expect(rendered).to.equal(expected);
});

it('should render JSX with multiple suspended direct children within a single suspense boundary that resolve one-after-another', async () => {
const {
Suspender: SuspenderOne,
suspended: suspendedOne
} = createSuspender();
const {
Suspender: SuspenderTwo,
suspended: suspendedTwo
} = createSuspender();
const {
Suspender: SuspenderThree,
suspended: suspendedThree
} = createSuspender();

const promise = renderToStringAsync(
<ul>
<Suspense fallback={null}>
<SuspenderOne>
<li>one</li>
</SuspenderOne>
<SuspenderTwo>
<li>two</li>
</SuspenderTwo>
<SuspenderThree>
<li>three</li>
</SuspenderThree>
</Suspense>
</ul>
);

const expected = `<ul><!--$s--><li>one</li><!--/$s--><!--$s--><li>two</li><!--/$s--><!--$s--><li>three</li><!--/$s--></ul>`;

suspendedOne.promise.then(() => { void suspendedTwo.resolve();});
suspendedTwo.promise.then(() => { void suspendedThree.resolve();});

suspendedOne.resolve();

const rendered = await promise;

expect(rendered).to.equal(expected);
});

it('should rethrow error thrown after suspending', async () => {
const { suspended, getResolved } = createSuspender();

Expand Down

0 comments on commit 24dbf7c

Please sign in to comment.