Skip to content

Commit

Permalink
also work for suspend then unsuspending later on client case
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Jan 27, 2022
1 parent 3594b2b commit 54aac5c
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ describe('ReactDOMServerPartialHydration', () => {
});

it('recovers with client render when server rendered additional nodes at suspense root after unsuspending', async () => {
spyOnDev(console, 'error');
const ref = React.createRef();
function App({hasB}) {
return (
Expand Down Expand Up @@ -526,8 +527,6 @@ describe('ReactDOMServerPartialHydration', () => {
ReactDOM.hydrateRoot(container, <App hasB={false} />);
});

spyOnDev(console, 'error');

resolve();
await promise;
Scheduler.unstable_flushAll();
Expand All @@ -542,13 +541,20 @@ describe('ReactDOMServerPartialHydration', () => {
expect(ref.current).toBe(span);
}

expect(console.error.calls.count()).toBe(1);
const errorArgs = console.error.calls.first().args;
if (gate(flags => flags.enableClientRenderFallbackOnHydrationMismatch)) {
expect(console.error.calls.count()).toBe(2);
const errorArgs = console.error.calls.all().shift().args;
expect(errorArgs[0]).toContain(
'An error occurred during hydration. The server HTML was replaced with client content',
);
} else {
expect(console.error.calls.count()).toBe(1);
}

const errorArgs = console.error.calls.all().pop().args;
expect(errorArgs[0]).toBe(
'Warning: Did not expect server HTML to contain a <%s> in <%s>.%s',
);
expect(errorArgs[1]).toBe('span');
expect(errorArgs[2]).toBe('div');
});

it('recovers with client render when server rendered additional nodes deep inside suspense root', async () => {
Expand Down

0 comments on commit 54aac5c

Please sign in to comment.