GeezerVison is showing github.com — Convert ResponderEventPlugin to createRoot (#28190) · react/react@6e1e92f
File tree
Expand file treeCollapse file tree
Open diff view settings
packages/react-native-renderer/src/__tests__
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: packages/react-native-renderer/src/__tests__/ResponderEventPlugin-test.internal.js +9-3Lines changed: 9 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1377,11 +1377,12 @@ describe('ResponderEventPlugin', () => { |
1377 | 1377 | expect(ResponderEventPlugin._getResponder()).toBe(null); |
1378 | 1378 | }); |
1379 | 1379 |
|
1380 | | - it('should determine the first common ancestor correctly', () => { |
| 1380 | + it('should determine the first common ancestor correctly', async () => { |
1381 | 1381 | // This test was moved here from the ReactTreeTraversal test since only the |
1382 | 1382 | // ResponderEventPlugin uses `getLowestCommonAncestor` |
1383 | 1383 | const React = require('react'); |
1384 | | - const ReactTestUtils = require('react-dom/test-utils'); |
| 1384 | + const ReactDOMClient = require('react-dom/client'); |
| 1385 | + const act = require('internal-test-utils').act; |
1385 | 1386 | const getLowestCommonAncestor = |
1386 | 1387 | require('react-native-renderer/src/legacy-events/ResponderEventPlugin').getLowestCommonAncestor; |
1387 | 1388 | // This works by accident and will likely break in the future. |
@@ -1422,7 +1423,12 @@ describe('ResponderEventPlugin', () => { |
1422 | 1423 | } |
1423 | 1424 | } |
1424 | 1425 |
|
1425 | | - const parent = ReactTestUtils.renderIntoDocument(<ParentComponent />); |
| 1426 | + const container = document.createElement('div'); |
| 1427 | + const root = ReactDOMClient.createRoot(container); |
| 1428 | + let parent; |
| 1429 | + await act(() => { |
| 1430 | + root.render(<ParentComponent ref={current => (parent = current)} />); |
| 1431 | + }); |
1426 | 1432 |
|
1427 | 1433 | const ancestors = [ |
1428 | 1434 | // Common ancestor with self is self. |
|