[tests] add assertLog for legacy mode tests (#28814)
A few more tests for https://github.com/facebook/react/pull/28737
Ricky committed
Apr 10, 2024 at 14:01 UTC
870e4045ab67020e9cc0f0940d46db7bbbffad3b
2 files changed
+5
-1
packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js
+4
-1
@@ -132,7 +132,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
132
expect(window.getComputedStyle(divs[0].current).display).toEqual('none');
133
expect(window.getComputedStyle(divs[1].current).display).toEqual('none');
134
expect(window.getComputedStyle(divs[2].current).display).toEqual('none');
135
-
135
+ assertLog(['A', 'Suspend! [B]', 'C', 'Loading...']);
136
await act(async () => {
137
await resolveText('B');
138
});
@@ -141,6 +141,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
141
expect(window.getComputedStyle(divs[1].current).display).toEqual('block');
142
// This div's display was set with a prop.
143
expect(window.getComputedStyle(divs[2].current).display).toEqual('inline');
144
+ assertLog(['B']);
145
});
146
147
it('hides and unhides timed out text nodes', async () => {
@@ -203,6 +204,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
204
'<span style="display: none;">Sibling</span><span style=' +
205
'"display: none;"></span>Loading...',
206
);
207
+ assertLog(['Suspend! [Async]', 'Loading...']);
208
209
// Update the inline display style. It will be overridden because it's
210
// inside a hidden fallback.
@@ -211,6 +213,7 @@ describe('ReactDOMSuspensePlaceholder', () => {
213
'<span style="display: none;">Sibling</span><span style=' +
214
'"display: none;"></span>Loading...',
215
);
216
+ assertLog(['Suspend! [Async]']);
217
218
// Unsuspend. The style should now match the inline prop.
219
await act(() => resolveText('Async'));
packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js
+1
@@ -1668,6 +1668,7 @@ describe('ReactLegacyUpdates', () => {
1668
await act(() => {
1669
ReactDOM.render(<Terminating />, container);
1670
});
1671
+ assertLog(Array.from({length: LIMIT + 1}, (_, k) => k));
1672
expect(container.textContent).toBe('50');
1673
await act(() => {
1674
_setStep(0);