Skip to content

Commit f8aba41

Browse files
gaearonBrian Vaughn
authored and
Brian Vaughn
committed
Make tests pass with different API names
1 parent d6f4790 commit f8aba41

17 files changed

+196
-204
lines changed

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let ReactFeatureFlags = require('shared/ReactFeatureFlags');
1414

1515
let ReactDOM;
1616

17-
const ConcurrentMode = React.unstable_ConcurrentMode;
17+
const ConcurrentMode = React.ConcurrentMode;
1818

1919
const setUntrackedInputValue = Object.getOwnPropertyDescriptor(
2020
HTMLInputElement.prototype,
@@ -163,7 +163,7 @@ describe('ReactDOMFiberAsync', () => {
163163
});
164164

165165
it('createRoot makes the entire tree async', () => {
166-
const root = ReactDOM.unstable_createRoot(container);
166+
const root = ReactDOM.createRoot(container);
167167
root.render(<div>Hi</div>);
168168
expect(container.textContent).toEqual('');
169169
jest.runAllTimers();
@@ -185,7 +185,7 @@ describe('ReactDOMFiberAsync', () => {
185185
}
186186
}
187187

188-
const root = ReactDOM.unstable_createRoot(container);
188+
const root = ReactDOM.createRoot(container);
189189
root.render(<Component />);
190190
expect(container.textContent).toEqual('');
191191
jest.runAllTimers();

packages/react-dom/src/__tests__/ReactDOMRoot-test.js

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
let React = require('react');
1313
let ReactDOM = require('react-dom');
1414
let ReactDOMServer = require('react-dom/server');
15-
let ConcurrentMode = React.unstable_ConcurrentMode;
15+
let ConcurrentMode = React.ConcurrentMode;
1616

1717
describe('ReactDOMRoot', () => {
1818
let container;
@@ -63,18 +63,18 @@ describe('ReactDOMRoot', () => {
6363
React = require('react');
6464
ReactDOM = require('react-dom');
6565
ReactDOMServer = require('react-dom/server');
66-
ConcurrentMode = React.unstable_ConcurrentMode;
66+
ConcurrentMode = React.ConcurrentMode;
6767
});
6868

6969
it('renders children', () => {
70-
const root = ReactDOM.unstable_createRoot(container);
70+
const root = ReactDOM.createRoot(container);
7171
root.render(<div>Hi</div>);
7272
jest.runAllTimers();
7373
expect(container.textContent).toEqual('Hi');
7474
});
7575

7676
it('unmounts children', () => {
77-
const root = ReactDOM.unstable_createRoot(container);
77+
const root = ReactDOM.createRoot(container);
7878
root.render(<div>Hi</div>);
7979
jest.runAllTimers();
8080
expect(container.textContent).toEqual('Hi');
@@ -84,7 +84,7 @@ describe('ReactDOMRoot', () => {
8484
});
8585

8686
it('`root.render` returns a thenable work object', () => {
87-
const root = ReactDOM.unstable_createRoot(container);
87+
const root = ReactDOM.createRoot(container);
8888
const work = root.render(<ConcurrentMode>Hi</ConcurrentMode>);
8989
let ops = [];
9090
work.then(() => {
@@ -102,7 +102,7 @@ describe('ReactDOMRoot', () => {
102102
});
103103

104104
it('resolves `work.then` callback synchronously if the work already committed', () => {
105-
const root = ReactDOM.unstable_createRoot(container);
105+
const root = ReactDOM.createRoot(container);
106106
const work = root.render(<ConcurrentMode>Hi</ConcurrentMode>);
107107
jest.runAllTimers();
108108
let ops = [];
@@ -126,7 +126,7 @@ describe('ReactDOMRoot', () => {
126126
// Does not hydrate by default
127127
const container1 = document.createElement('div');
128128
container1.innerHTML = markup;
129-
const root1 = ReactDOM.unstable_createRoot(container1);
129+
const root1 = ReactDOM.createRoot(container1);
130130
root1.render(
131131
<div>
132132
<span />
@@ -137,7 +137,7 @@ describe('ReactDOMRoot', () => {
137137
// Accepts `hydrate` option
138138
const container2 = document.createElement('div');
139139
container2.innerHTML = markup;
140-
const root2 = ReactDOM.unstable_createRoot(container2, {hydrate: true});
140+
const root2 = ReactDOM.createRoot(container2, {hydrate: true});
141141
root2.render(
142142
<div>
143143
<span />
@@ -150,7 +150,7 @@ describe('ReactDOMRoot', () => {
150150

151151
it('does not clear existing children', async () => {
152152
container.innerHTML = '<div>a</div><div>b</div>';
153-
const root = ReactDOM.unstable_createRoot(container);
153+
const root = ReactDOM.createRoot(container);
154154
root.render(
155155
<div>
156156
<span>c</span>
@@ -170,7 +170,7 @@ describe('ReactDOMRoot', () => {
170170
});
171171

172172
it('can defer a commit by batching it', () => {
173-
const root = ReactDOM.unstable_createRoot(container);
173+
const root = ReactDOM.createRoot(container);
174174
const batch = root.createBatch();
175175
batch.render(<div>Hi</div>);
176176
// Hasn't committed yet
@@ -193,7 +193,7 @@ describe('ReactDOMRoot', () => {
193193
}
194194
}
195195

196-
const root = ReactDOM.unstable_createRoot(container);
196+
const root = ReactDOM.createRoot(container);
197197
const batch = root.createBatch();
198198
batch.render(
199199
<ConcurrentMode>
@@ -226,7 +226,7 @@ describe('ReactDOMRoot', () => {
226226
ops.push('Foo');
227227
return props.children;
228228
}
229-
const root = ReactDOM.unstable_createRoot(container);
229+
const root = ReactDOM.createRoot(container);
230230
const batch = root.createBatch();
231231
batch.render(<Foo>Hi</Foo>);
232232
// Flush all async work.
@@ -244,7 +244,7 @@ describe('ReactDOMRoot', () => {
244244
});
245245

246246
it('can wait for a batch to finish', () => {
247-
const root = ReactDOM.unstable_createRoot(container);
247+
const root = ReactDOM.createRoot(container);
248248
const batch = root.createBatch();
249249
batch.render(<ConcurrentMode>Foo</ConcurrentMode>);
250250

@@ -266,7 +266,7 @@ describe('ReactDOMRoot', () => {
266266
});
267267

268268
it('`batch.render` returns a thenable work object', () => {
269-
const root = ReactDOM.unstable_createRoot(container);
269+
const root = ReactDOM.createRoot(container);
270270
const batch = root.createBatch();
271271
const work = batch.render('Hi');
272272
let ops = [];
@@ -285,7 +285,7 @@ describe('ReactDOMRoot', () => {
285285
});
286286

287287
it('can commit an empty batch', () => {
288-
const root = ReactDOM.unstable_createRoot(container);
288+
const root = ReactDOM.createRoot(container);
289289
root.render(<ConcurrentMode>1</ConcurrentMode>);
290290

291291
advanceCurrentTime(2000);
@@ -302,7 +302,7 @@ describe('ReactDOMRoot', () => {
302302

303303
it('two batches created simultaneously are committed separately', () => {
304304
// (In other words, they have distinct expiration times)
305-
const root = ReactDOM.unstable_createRoot(container);
305+
const root = ReactDOM.createRoot(container);
306306
const batch1 = root.createBatch();
307307
batch1.render(1);
308308
const batch2 = root.createBatch();
@@ -318,7 +318,7 @@ describe('ReactDOMRoot', () => {
318318
});
319319

320320
it('commits an earlier batch without committing a later batch', () => {
321-
const root = ReactDOM.unstable_createRoot(container);
321+
const root = ReactDOM.createRoot(container);
322322
const batch1 = root.createBatch();
323323
batch1.render(1);
324324

@@ -337,7 +337,7 @@ describe('ReactDOMRoot', () => {
337337
});
338338

339339
it('commits a later batch without committing an earlier batch', () => {
340-
const root = ReactDOM.unstable_createRoot(container);
340+
const root = ReactDOM.createRoot(container);
341341
const batch1 = root.createBatch();
342342
batch1.render(1);
343343

@@ -357,7 +357,7 @@ describe('ReactDOMRoot', () => {
357357
});
358358

359359
it('handles fatal errors triggered by batch.commit()', () => {
360-
const root = ReactDOM.unstable_createRoot(container);
360+
const root = ReactDOM.createRoot(container);
361361
const batch = root.createBatch();
362362
const InvalidType = undefined;
363363
expect(() => batch.render(<InvalidType />)).toWarnDev(
@@ -369,9 +369,7 @@ describe('ReactDOMRoot', () => {
369369

370370
it('throws a good message on invalid containers', () => {
371371
expect(() => {
372-
ReactDOM.unstable_createRoot(<div>Hi</div>);
373-
}).toThrow(
374-
'unstable_createRoot(...): Target container is not a DOM element.',
375-
);
372+
ReactDOM.createRoot(<div>Hi</div>);
373+
}).toThrow('createRoot(...): Target container is not a DOM element.');
376374
});
377375
});

packages/react-dom/src/__tests__/ReactDOMServerIntegrationModes-test.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ describe('ReactDOMServerIntegration', () => {
104104
});
105105
});
106106

107-
describe('React.unstable_ConcurrentMode', () => {
107+
describe('React.ConcurrentMode', () => {
108108
itRenders('an concurrent mode with one child', async render => {
109109
let e = await render(
110-
<React.unstable_ConcurrentMode>
110+
<React.ConcurrentMode>
111111
<div>text1</div>
112-
</React.unstable_ConcurrentMode>,
112+
</React.ConcurrentMode>,
113113
);
114114
let parent = e.parentNode;
115115
expect(parent.childNodes[0].tagName).toBe('DIV');
@@ -121,19 +121,19 @@ describe('ReactDOMServerIntegration', () => {
121121
};
122122
let Footer = props => {
123123
return (
124-
<React.unstable_ConcurrentMode>
124+
<React.ConcurrentMode>
125125
<h2>footer</h2>
126126
<h3>about</h3>
127-
</React.unstable_ConcurrentMode>
127+
</React.ConcurrentMode>
128128
);
129129
};
130130
let e = await render(
131-
<React.unstable_ConcurrentMode>
131+
<React.ConcurrentMode>
132132
<div>text1</div>
133133
<span>text2</span>
134134
<Header />
135135
<Footer />
136-
</React.unstable_ConcurrentMode>,
136+
</React.ConcurrentMode>,
137137
);
138138
let parent = e.parentNode;
139139
expect(parent.childNodes[0].tagName).toBe('DIV');
@@ -145,21 +145,21 @@ describe('ReactDOMServerIntegration', () => {
145145

146146
itRenders('a nested concurrent mode', async render => {
147147
let e = await render(
148-
<React.unstable_ConcurrentMode>
149-
<React.unstable_ConcurrentMode>
148+
<React.ConcurrentMode>
149+
<React.ConcurrentMode>
150150
<div>text1</div>
151-
</React.unstable_ConcurrentMode>
151+
</React.ConcurrentMode>
152152
<span>text2</span>
153-
<React.unstable_ConcurrentMode>
154-
<React.unstable_ConcurrentMode>
155-
<React.unstable_ConcurrentMode>
153+
<React.ConcurrentMode>
154+
<React.ConcurrentMode>
155+
<React.ConcurrentMode>
156156
{null}
157157
<p />
158-
</React.unstable_ConcurrentMode>
158+
</React.ConcurrentMode>
159159
{false}
160-
</React.unstable_ConcurrentMode>
161-
</React.unstable_ConcurrentMode>
162-
</React.unstable_ConcurrentMode>,
160+
</React.ConcurrentMode>
161+
</React.ConcurrentMode>
162+
</React.ConcurrentMode>,
163163
);
164164
let parent = e.parentNode;
165165
expect(parent.childNodes[0].tagName).toBe('DIV');
@@ -168,7 +168,7 @@ describe('ReactDOMServerIntegration', () => {
168168
});
169169

170170
itRenders('an empty concurrent mode', async render => {
171-
expect(await render(<React.unstable_ConcurrentMode />)).toBe(null);
171+
expect(await render(<React.ConcurrentMode />)).toBe(null);
172172
});
173173
});
174174
});

packages/react-dom/src/__tests__/ReactDOMServerIntegrationSpecialTypes-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ describe('ReactDOMServerIntegration', () => {
7373

7474
itRenders('a Profiler component and its children', async render => {
7575
const element = await render(
76-
<React.unstable_Profiler id="profiler" onRender={jest.fn()}>
76+
<React.Profiler id="profiler" onRender={jest.fn()}>
7777
<div>Test</div>
78-
</React.unstable_Profiler>,
78+
</React.Profiler>,
7979
);
8080
const parent = element.parentNode;
8181
const div = parent.childNodes[0];

packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ describe('ReactDOMServerHydration', () => {
391391
it('should be able to render and hydrate Profiler components', () => {
392392
const callback = jest.fn();
393393
const markup = (
394-
<React.unstable_Profiler id="profiler" onRender={callback}>
394+
<React.Profiler id="profiler" onRender={callback}>
395395
<div>Hi</div>
396-
</React.unstable_Profiler>
396+
</React.Profiler>
397397
);
398398

399399
const element = document.createElement('div');

packages/react-dom/src/events/__tests__/ChangeEventPlugin-test.internal.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ describe('ChangeEventPlugin', () => {
486486
ReactDOM = require('react-dom');
487487
});
488488
it('text input', () => {
489-
const root = ReactDOM.unstable_createRoot(container);
489+
const root = ReactDOM.createRoot(container);
490490
let input;
491491

492492
let ops = [];
@@ -533,7 +533,7 @@ describe('ChangeEventPlugin', () => {
533533
});
534534

535535
it('checkbox input', () => {
536-
const root = ReactDOM.unstable_createRoot(container);
536+
const root = ReactDOM.createRoot(container);
537537
let input;
538538

539539
let ops = [];
@@ -595,7 +595,7 @@ describe('ChangeEventPlugin', () => {
595595
});
596596

597597
it('textarea', () => {
598-
const root = ReactDOM.unstable_createRoot(container);
598+
const root = ReactDOM.createRoot(container);
599599
let textarea;
600600

601601
let ops = [];
@@ -642,7 +642,7 @@ describe('ChangeEventPlugin', () => {
642642
});
643643

644644
it('parent of input', () => {
645-
const root = ReactDOM.unstable_createRoot(container);
645+
const root = ReactDOM.createRoot(container);
646646
let input;
647647

648648
let ops = [];
@@ -693,7 +693,7 @@ describe('ChangeEventPlugin', () => {
693693
});
694694

695695
it('is async for non-input events', () => {
696-
const root = ReactDOM.unstable_createRoot(container);
696+
const root = ReactDOM.createRoot(container);
697697
let input;
698698

699699
let ops = [];

packages/react-dom/src/events/__tests__/SimpleEventPlugin-test.internal.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe('SimpleEventPlugin', function() {
262262

263263
it('flushes pending interactive work before extracting event handler', () => {
264264
container = document.createElement('div');
265-
const root = ReactDOM.unstable_createRoot(container);
265+
const root = ReactDOM.createRoot(container);
266266
document.body.appendChild(container);
267267

268268
let ops = [];
@@ -342,7 +342,7 @@ describe('SimpleEventPlugin', function() {
342342

343343
it('end result of many interactive updates is deterministic', () => {
344344
container = document.createElement('div');
345-
const root = ReactDOM.unstable_createRoot(container);
345+
const root = ReactDOM.createRoot(container);
346346
document.body.appendChild(container);
347347

348348
let button;
@@ -426,9 +426,9 @@ describe('SimpleEventPlugin', function() {
426426
// Intentionally not using the updater form here
427427
() => this.setState({highPriCount: this.state.highPriCount + 1})
428428
}>
429-
<React.unstable_ConcurrentMode>
429+
<React.ConcurrentMode>
430430
<Button highPriCount={this.state.highPriCount} />
431-
</React.unstable_ConcurrentMode>
431+
</React.ConcurrentMode>
432432
</div>
433433
);
434434
}

0 commit comments

Comments
 (0)