Last active
April 14, 2022 19:52
-
-
Save tanner-west/adc3af779724ddae074add5c4784313c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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