Test should ensure that update is applied before corresponding render
Tightens up the test a bit to prevent regressions.
Andrew Clark committed
Feb 21, 2017 at 16:47 UTC
d649ebc6e130c1cb5180b61de62ca79b4c01adf9
1 file changed
+7
-2
src/renderers/__tests__/ReactCompositeComponentState-test.js
+7
-2
@@ -424,12 +424,13 @@ describe('ReactCompositeComponent-state', () => {
424
componentWillReceiveProps() {
425
this.setState({ step: 2 }, () => {
426
// Tests that earlier setState callbacks are not dropped
427
- ops.push(`step: ${this.state.step}, extra: ${!!this.state.extra}`);
427
+ ops.push(`callback -- step: ${this.state.step}, extra: ${!!this.state.extra}`);
428
});
429
// Treat like replaceState
430
this.state = { step: 3 };
431
}
432
render() {
433
+ ops.push(`render -- step: ${this.state.step}, extra: ${!!this.state.extra}`);
434
return null;
435
}
436
}
@@ -440,7 +441,11 @@ describe('ReactCompositeComponent-state', () => {
441
// Update
442
ReactDOM.render(<Test />, container);
443
443
- expect(ops).toEqual(['step: 3, extra: false']);
444
+ expect(ops).toEqual([
445
+ 'render -- step: 1, extra: true',
446
+ 'render -- step: 3, extra: false',
447
+ 'callback -- step: 3, extra: false',
448
+ ]);
449
expect(console.error.calls.count()).toEqual(1);
450
expect(console.error.calls.argsFor(0)[0]).toEqual(
451
'Warning: Test.componentWillReceiveProps(): Assigning directly to ' +