Skip to content

Commit

Permalink
Check correct commit phase props in fuzz tester (facebook#14129)
Browse files Browse the repository at this point in the history
Adds a check to the existing fuzz tester to confirm that the props are
set to the latest values in the commit phase. Only checks
componentDidUpdate; we already have unit tests for the other lifecycles,
so I think this is good enough. This is only a redundancy.
  • Loading branch information
acdlite authored and jetoneza committed Jan 23, 2019
1 parent 9d60dcc commit 0de322c
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ describe('ReactIncrementalTriangle', () => {
leafTriangles.push(this);
}
this.state = {isActive: false};
this.child = React.createRef(null);
}
activate() {
this.setState({isActive: true});
Expand All @@ -203,6 +204,14 @@ describe('ReactIncrementalTriangle', () => {
this.state.isActive !== nextState.isActive
);
}
componentDidUpdate() {
if (this.child.current !== null) {
const {prop: currentCounter} = JSON.parse(this.child.current.prop);
if (this.props.counter !== currentCounter) {
throw new Error('Incorrect props in lifecycle');
}
}
}
render() {
if (yieldAfterEachRender) {
ReactNoop.yield(this);
Expand All @@ -228,7 +237,7 @@ describe('ReactIncrementalTriangle', () => {
activeDepthProp,
activeDepthContext,
});
return <span prop={output} />;
return <span ref={this.child} prop={output} />;
}

return (
Expand Down

0 comments on commit 0de322c

Please sign in to comment.