Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RTR from StrictEffectsMode-test #28387

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 51 additions & 71 deletions packages/react-reconciler/src/__tests__/StrictEffectsMode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@
'use strict';

let React;
let ReactTestRenderer;
let ReactDOMClient;
let ReactDOM;
let Scheduler;
let act;
let assertLog;
let container;

describe('StrictEffectsMode', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
ReactTestRenderer = require('react-test-renderer');
Scheduler = require('scheduler');
act = require('internal-test-utils').act;

const InternalTestUtils = require('internal-test-utils');
assertLog = InternalTestUtils.assertLog;

React = require('react');
Scheduler = require('scheduler');
ReactDOMClient = require('react-dom/client');
ReactDOM = require('react-dom');
container = document.createElement('div');
});

it('should not double invoke effects in legacy mode', async () => {
Expand All @@ -43,10 +47,11 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
ReactTestRenderer.create(
ReactDOM.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
container,
);
});

Expand All @@ -68,15 +73,12 @@ describe('StrictEffectsMode', () => {
return text;
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -94,7 +96,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -109,7 +111,7 @@ describe('StrictEffectsMode', () => {
]);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog(['useLayoutEffect unmount', 'useEffect unmount']);
Expand All @@ -130,15 +132,12 @@ describe('StrictEffectsMode', () => {
return text;
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -156,7 +155,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -171,7 +170,7 @@ describe('StrictEffectsMode', () => {
]);

await act(() => {
renderer.unmount(null);
root.unmount(null);
});

assertLog(['useEffect One unmount', 'useEffect Two unmount']);
Expand All @@ -192,15 +191,12 @@ describe('StrictEffectsMode', () => {
return text;
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -218,7 +214,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -233,7 +229,7 @@ describe('StrictEffectsMode', () => {
]);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog(['useLayoutEffect One unmount', 'useLayoutEffect Two unmount']);
Expand All @@ -252,15 +248,12 @@ describe('StrictEffectsMode', () => {
return text;
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -276,7 +269,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -286,7 +279,7 @@ describe('StrictEffectsMode', () => {
assertLog(['useLayoutEffect mount', 'useEffect mount']);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog([]);
Expand Down Expand Up @@ -316,12 +309,12 @@ describe('StrictEffectsMode', () => {
}
}

const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
{isConcurrent: true},
);
});

Expand Down Expand Up @@ -355,15 +348,12 @@ describe('StrictEffectsMode', () => {
}
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -378,7 +368,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -388,7 +378,7 @@ describe('StrictEffectsMode', () => {
assertLog(['componentDidUpdate']);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog(['componentWillUnmount']);
Expand All @@ -409,15 +399,12 @@ describe('StrictEffectsMode', () => {
}
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -428,7 +415,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'update'} />
</React.StrictMode>,
Expand All @@ -438,7 +425,7 @@ describe('StrictEffectsMode', () => {
assertLog(['componentDidUpdate']);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog(['componentWillUnmount']);
Expand All @@ -464,10 +451,11 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
ReactTestRenderer.create(
ReactDOM.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
container,
);
});

Expand All @@ -494,14 +482,12 @@ describe('StrictEffectsMode', () => {
return text;
}

const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand Down Expand Up @@ -564,12 +550,12 @@ describe('StrictEffectsMode', () => {
return showChild && <Child />;
}

const root = ReactDOMClient.createRoot(container);
await act(() => {
ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
{isConcurrent: true},
);
});

Expand Down Expand Up @@ -651,15 +637,12 @@ describe('StrictEffectsMode', () => {
);
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -684,7 +667,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
Expand All @@ -699,7 +682,7 @@ describe('StrictEffectsMode', () => {
]);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog([
Expand Down Expand Up @@ -741,15 +724,12 @@ describe('StrictEffectsMode', () => {
);
}

let renderer;
const root = ReactDOMClient.createRoot(container);
await act(() => {
renderer = ReactTestRenderer.create(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
{
isConcurrent: true,
},
);
});

Expand All @@ -768,7 +748,7 @@ describe('StrictEffectsMode', () => {
}

await act(() => {
renderer.update(
root.render(
<React.StrictMode>
<App text={'mount'} />
</React.StrictMode>,
Expand All @@ -783,7 +763,7 @@ describe('StrictEffectsMode', () => {
]);

await act(() => {
renderer.unmount();
root.unmount();
});

assertLog([
Expand Down