Skip to content

Instantly share code, notes, and snippets.

@tanner-west
Last active April 14, 2022 19:52
Show Gist options
  • Save tanner-west/adc3af779724ddae074add5c4784313c to your computer and use it in GitHub Desktop.
Save tanner-west/adc3af779724ddae074add5c4784313c to your computer and use it in GitHub Desktop.
// Consider a class component with this method that's called when a button is pressed:
onMultiplierChanged(multiplier) {
this.setState({product: (parseInt(multiplier) * 12).toString()});
}
// A test utilizing wrapper.instance might look like this:
it('Should update state when onMultiplierChanged method is called', () => {
const instance = wrapper.instance();
instance.onMultiplierChanged("12");
expect(wrapper.state('product')).toEqual("144");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment