0
jestのコンポーネントの状態を更新しようとしています。jestを使用しているコンポーネントの状態を更新します。
updated
の状態値がtrue
に設定されている場合、新しい小道具が状態の値を変更すべきではないことを確認してください。 私がここで読んだ答えから、コンポーネントの状態を更新するために次のことができると仮定しました。
Game.setState({
updated: true
});
以下は私のコードです。
const props = {
goals: "0"
};
it("should should not update the state of goals when the value prop is changed if updated value in state is set to true",() => {
renderer.render(<Game {...props} />, div);
Game.setState({
updated: true
});
Game.componentWillReceiveProps({
goals: "2"
});
expect(Game.state.goals).toBe("0");
});