Skip to content

Commit da021ca

Browse files
authored
Use ReactDOM.unstable_batchedUpdates in Fiber tests (#8263)
1 parent a9fa135 commit da021ca

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

scripts/fiber/tests-failing.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,20 +567,9 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
567567
* should warn when using non-React functions in JSX
568568

569569
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
570-
* should batch state when updating state twice
571-
* should batch state when updating two different state keys
572-
* should batch state and props together
573-
* should batch parent/child state updates together
574-
* should batch child/parent state updates together
575-
* should support chained state updates
576-
* should batch forceUpdate together
577-
* should update children even if parent blocks updates
578-
* should flow updates correctly
579570
* should share reconcile transaction across different roots
580571
* should queue mount-ready handlers across different roots
581-
* should flush updates in the correct order across roots
582572
* should queue updates from during mount
583-
* does not call render after a component as been deleted
584573
* marks top-level updates
585574
* throws in setState if the update callback is not a function
586575
* throws in replaceState if the update callback is not a function

scripts/fiber/tests-passing.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,21 @@ src/renderers/shared/stack/reconciler/__tests__/ReactStatelessComponent-test.js
11551155
* should allow simple functions to return false
11561156

11571157
src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js
1158+
* should batch state when updating state twice
1159+
* should batch state when updating two different state keys
1160+
* should batch state and props together
1161+
* should batch parent/child state updates together
1162+
* should batch child/parent state updates together
1163+
* should support chained state updates
1164+
* should batch forceUpdate together
1165+
* should update children even if parent blocks updates
11581166
* should not reconcile children passed via props
1167+
* should flow updates correctly
11591168
* should flush updates in the correct order
1169+
* should flush updates in the correct order across roots
11601170
* should queue nested updates
11611171
* calls componentWillReceiveProps setState callback properly
1172+
* does not call render after a component as been deleted
11621173
* does not update one component twice in a batch (#2410)
11631174
* does not update one component twice in a batch (#6371)
11641175
* unstable_batchedUpdates should return value from a callback

src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var ReactCurrentOwner;
1919
var ReactPropTypes;
2020
var ReactServerRendering;
2121
var ReactTestUtils;
22-
var ReactUpdates;
2322

2423
describe('ReactCompositeComponent', () => {
2524

@@ -31,7 +30,6 @@ describe('ReactCompositeComponent', () => {
3130
ReactPropTypes = require('ReactPropTypes');
3231
ReactTestUtils = require('ReactTestUtils');
3332
ReactServerRendering = require('ReactServerRendering');
34-
ReactUpdates = require('ReactUpdates');
3533

3634
MorphingComponent = class extends React.Component {
3735
state = {activated: false};
@@ -813,7 +811,7 @@ describe('ReactCompositeComponent', () => {
813811
expect(childInstance).toBeNull();
814812

815813
expect(parentInstance.state.flag).toBe(false);
816-
ReactUpdates.batchedUpdates(function() {
814+
ReactDOM.unstable_batchedUpdates(function() {
817815
parentInstance.setState({flag: true});
818816
});
819817
expect(parentInstance.state.flag).toBe(true);
@@ -1209,15 +1207,15 @@ describe('ReactCompositeComponent', () => {
12091207

12101208
// When more than one state update is enqueued, we have the same behavior
12111209
var fifthState = new NotActuallyImmutable('fifth');
1212-
ReactUpdates.batchedUpdates(function() {
1210+
ReactDOM.unstable_batchedUpdates(function() {
12131211
moo.setState({str: 'fourth'});
12141212
moo.replaceState(fifthState);
12151213
});
12161214
expect(moo.state).toBe(fifthState);
12171215

12181216
// When more than one state update is enqueued, we have the same behavior
12191217
var sixthState = new NotActuallyImmutable('sixth');
1220-
ReactUpdates.batchedUpdates(function() {
1218+
ReactDOM.unstable_batchedUpdates(function() {
12211219
moo.replaceState(sixthState);
12221220
moo.setState({str: 'seventh'});
12231221
});

src/renderers/shared/stack/reconciler/__tests__/ReactUpdates-test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('ReactUpdates', () => {
4242
var instance = ReactTestUtils.renderIntoDocument(<Component />);
4343
expect(instance.state.x).toBe(0);
4444

45-
ReactUpdates.batchedUpdates(function() {
45+
ReactDOM.unstable_batchedUpdates(function() {
4646
instance.setState({x: 1});
4747
instance.setState({x: 2});
4848
expect(instance.state.x).toBe(0);
@@ -72,7 +72,7 @@ describe('ReactUpdates', () => {
7272
expect(instance.state.x).toBe(0);
7373
expect(instance.state.y).toBe(0);
7474

75-
ReactUpdates.batchedUpdates(function() {
75+
ReactDOM.unstable_batchedUpdates(function() {
7676
instance.setState({x: 1});
7777
instance.setState({y: 2});
7878
expect(instance.state.x).toBe(0);
@@ -105,7 +105,7 @@ describe('ReactUpdates', () => {
105105
expect(instance.props.x).toBe(0);
106106
expect(instance.state.y).toBe(0);
107107

108-
ReactUpdates.batchedUpdates(function() {
108+
ReactDOM.unstable_batchedUpdates(function() {
109109
ReactDOM.render(<Component x={1} />, container);
110110
instance.setState({y: 2});
111111
expect(instance.props.x).toBe(0);
@@ -152,7 +152,7 @@ describe('ReactUpdates', () => {
152152
expect(instance.state.x).toBe(0);
153153
expect(child.state.y).toBe(0);
154154

155-
ReactUpdates.batchedUpdates(function() {
155+
ReactDOM.unstable_batchedUpdates(function() {
156156
instance.setState({x: 1});
157157
child.setState({y: 2});
158158
expect(instance.state.x).toBe(0);
@@ -201,7 +201,7 @@ describe('ReactUpdates', () => {
201201
expect(instance.state.x).toBe(0);
202202
expect(child.state.y).toBe(0);
203203

204-
ReactUpdates.batchedUpdates(function() {
204+
ReactDOM.unstable_batchedUpdates(function() {
205205
child.setState({y: 2});
206206
instance.setState({x: 1});
207207
expect(instance.state.x).toBe(0);
@@ -237,7 +237,7 @@ describe('ReactUpdates', () => {
237237
expect(instance.state.x).toBe(0);
238238

239239
var innerCallbackRun = false;
240-
ReactUpdates.batchedUpdates(function() {
240+
ReactDOM.unstable_batchedUpdates(function() {
241241
instance.setState({x: 1}, function() {
242242
instance.setState({x: 2}, function() {
243243
expect(this).toBe(instance);
@@ -281,7 +281,7 @@ describe('ReactUpdates', () => {
281281
expect(instance.state.x).toBe(0);
282282

283283
var callbacksRun = 0;
284-
ReactUpdates.batchedUpdates(function() {
284+
ReactDOM.unstable_batchedUpdates(function() {
285285
instance.setState({x: 1}, function() {
286286
callbacksRun++;
287287
});
@@ -330,14 +330,14 @@ describe('ReactUpdates', () => {
330330
expect(parentRenderCount).toBe(1);
331331
expect(childRenderCount).toBe(1);
332332

333-
ReactUpdates.batchedUpdates(function() {
333+
ReactDOM.unstable_batchedUpdates(function() {
334334
instance.setState({x: 1});
335335
});
336336

337337
expect(parentRenderCount).toBe(1);
338338
expect(childRenderCount).toBe(1);
339339

340-
ReactUpdates.batchedUpdates(function() {
340+
ReactDOM.unstable_batchedUpdates(function() {
341341
instance.refs.child.setState({x: 1});
342342
});
343343

@@ -465,7 +465,7 @@ describe('ReactUpdates', () => {
465465
function testUpdates(components, desiredWillUpdates, desiredDidUpdates) {
466466
var i;
467467

468-
ReactUpdates.batchedUpdates(function() {
468+
ReactDOM.unstable_batchedUpdates(function() {
469469
for (i = 0; i < components.length; i++) {
470470
triggerUpdate(components[i]);
471471
}
@@ -475,7 +475,7 @@ describe('ReactUpdates', () => {
475475

476476
// Try them in reverse order
477477

478-
ReactUpdates.batchedUpdates(function() {
478+
ReactDOM.unstable_batchedUpdates(function() {
479479
for (i = components.length - 1; i >= 0; i--) {
480480
triggerUpdate(components[i]);
481481
}
@@ -519,15 +519,15 @@ describe('ReactUpdates', () => {
519519
var containerB = document.createElement('div');
520520

521521
// Initial renders aren't batched together yet...
522-
ReactUpdates.batchedUpdates(function() {
522+
ReactDOM.unstable_batchedUpdates(function() {
523523
ReactDOM.render(<Component text="A1" />, containerA);
524524
ReactDOM.render(<Component text="B1" />, containerB);
525525
});
526526
expect(ReconcileTransaction.getPooled.calls.count()).toBe(2);
527527

528528
// ...but updates are! Here only one more transaction is used, which means
529529
// we only have to initialize and close the wrappers once.
530-
ReactUpdates.batchedUpdates(function() {
530+
ReactDOM.unstable_batchedUpdates(function() {
531531
ReactDOM.render(<Component text="A2" />, containerA);
532532
ReactDOM.render(<Component text="B2" />, containerB);
533533
});
@@ -568,7 +568,7 @@ describe('ReactUpdates', () => {
568568
a = ReactTestUtils.renderIntoDocument(<A />);
569569
b = ReactTestUtils.renderIntoDocument(<B />);
570570

571-
ReactUpdates.batchedUpdates(function() {
571+
ReactDOM.unstable_batchedUpdates(function() {
572572
a.setState({x: 1});
573573
b.setState({x: 1});
574574
});
@@ -679,7 +679,7 @@ describe('ReactUpdates', () => {
679679

680680
expect(updates).toEqual([0, 1, 2]);
681681

682-
ReactUpdates.batchedUpdates(function() {
682+
ReactDOM.unstable_batchedUpdates(function() {
683683
// Simulate update on each component from top to bottom.
684684
instances.forEach(function(instance) {
685685
instance.forceUpdate();
@@ -771,7 +771,7 @@ describe('ReactUpdates', () => {
771771
}
772772
}
773773

774-
ReactUpdates.batchedUpdates(function() {
774+
ReactDOM.unstable_batchedUpdates(function() {
775775
ReactTestUtils.renderIntoDocument(
776776
<div>
777777
<A />
@@ -837,7 +837,7 @@ describe('ReactUpdates', () => {
837837

838838
var component = ReactTestUtils.renderIntoDocument(<A />);
839839

840-
ReactUpdates.batchedUpdates(function() {
840+
ReactDOM.unstable_batchedUpdates(function() {
841841
// B will have scheduled an update but the batching should ensure that its
842842
// update never fires.
843843
componentB.setState({updates: 1});

0 commit comments

Comments
 (0)