Skip to content

Commit

Permalink
Convert ReactDOMSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed Jan 31, 2024
1 parent d29f7d9 commit 1d3f1c4
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions packages/react-dom/src/__tests__/ReactDOMSelection-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
'use strict';

let React;
let ReactDOM;
let ReactDOMClient;
let ReactDOMSelection;
let act;

let getModernOffsetsFromPoints;

describe('ReactDOMSelection', () => {
beforeEach(() => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactDOMSelection = require('react-dom-bindings/src/client/ReactDOMSelection');
act = require('internal-test-utils').act;

({getModernOffsetsFromPoints} = ReactDOMSelection);
});
Expand Down Expand Up @@ -74,53 +76,57 @@ describe('ReactDOMSelection', () => {

// Complicated example derived from a real-world DOM tree. Has a bit of
// everything.
function getFixture() {
return ReactDOM.render(
<div>
async function getFixture() {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(
<div>
<div>
<div>xxxxxxxxxxxxxxxxxxxx</div>
</div>
x
<div>
<div>
x
<div>xxxxxxxxxxxxxxxxxxxx</div>
</div>
x
<div>
<div>
x
<div>
<div>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div />
<div />
<div>xxxxxxxxxxxxxxxxxx</div>
<div>
<div>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</div>
<div />
<div />
<div>xxxxxxxxxxxxxxxxxx</div>
</div>
</div>
</div>
</div>
<div />
</div>
<div />
</div>
<div>
<div>
<div>
<div>xxxx</div>
<div>xxxxxxxxxxxxxxxxxxx</div>
<div>
<div>xxxx</div>
<div>xxxxxxxxxxxxxxxxxxx</div>
</div>
</div>
</div>
<div>xxx</div>
<div>xxxxx</div>
<div>xxx</div>
<div>
<div>xxx</div>
<div>xxxxx</div>
<div>xxx</div>
<div>
<div>
<div>{['x', 'x', 'xxx']}</div>
<div>
<div>{['x', 'x', 'xxx']}</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>xxxxxx</div>
</div>
</div>,
document.createElement('div'),
);
<div>
<div>xxxxxx</div>
</div>
</div>,
);
});
return container.firstChild;
}

it('returns correctly for base case', () => {
Expand All @@ -135,8 +141,8 @@ describe('ReactDOMSelection', () => {
});
});

it('returns correctly for fuzz test', () => {
const fixtureRoot = getFixture();
it('returns correctly for fuzz test', async () => {
const fixtureRoot = await getFixture();
const allNodes = [fixtureRoot].concat(
Array.from(fixtureRoot.querySelectorAll('*')),
);
Expand Down

0 comments on commit 1d3f1c4

Please sign in to comment.