From 686bed8c8d5d86d856541626c5d848429d7bde31 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 6 May 2024 23:04:09 +0200 Subject: [PATCH] Keep log assertions small The longer the list of log lines asserted one, the harder future diffs are to comprehend. git-diff produces hard to decipher diffs if the StrictEffects behavior is changed slightly that results in more lines added. It won't be obvious anymore which lines were added and which ones were removed. --- .../src/__tests__/StrictEffectsMode-test.js | 57 +++++++------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js b/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js index 646638e9ed2d6..bd458b2cd5328 100644 --- a/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js +++ b/packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js @@ -900,8 +900,17 @@ describe('StrictEffectsMode', () => { ); }); + expect(log).toEqual([ + 'Parent rendered', + 'Parent rendered', + 'Child rendered', + 'Child suspended', + 'Fallback', + 'Fallback', + ]); + + log = []; // while suspended, update - log.push('-----------------------after update'); await act(() => { ReactNoop.render( @@ -910,9 +919,19 @@ describe('StrictEffectsMode', () => { ); }); - // Now resolve and commit - log.push('-----------------------after suspense'); + expect(log).toEqual([ + 'Parent rendered', + 'Parent rendered', + 'Child rendered', + 'Child suspended', + 'Fallback', + 'Fallback', + 'Parent dep destroy', + 'Parent dep create', + ]); + log = []; + // Now resolve and commit await act(() => { resolve(); shouldSuspend = false; @@ -920,22 +939,6 @@ describe('StrictEffectsMode', () => { if (gate(flags => flags.useModernStrictMode)) { expect(log).toEqual([ - 'Parent rendered', - 'Parent rendered', - 'Child rendered', - 'Child suspended', - 'Fallback', - 'Fallback', - '-----------------------after update', - 'Parent rendered', - 'Parent rendered', - 'Child rendered', - 'Child suspended', - 'Fallback', - 'Fallback', - 'Parent dep destroy', - 'Parent dep create', - '-----------------------after suspense', 'Child rendered', 'Child rendered', // !!! Committed, destroy and create effect. @@ -957,22 +960,6 @@ describe('StrictEffectsMode', () => { ]); } else { expect(log).toEqual([ - 'Parent rendered', - 'Parent rendered', - 'Child rendered', - 'Child suspended', - 'Fallback', - 'Fallback', - '-----------------------after update', - 'Parent rendered', - 'Parent rendered', - 'Child rendered', - 'Child suspended', - 'Fallback', - 'Fallback', - 'Parent dep destroy', - 'Parent dep create', - '-----------------------after suspense', 'Child rendered', 'Child rendered', 'Child dep destroy',