-
Notifications
You must be signed in to change notification settings - Fork 1.3k
test: Make sure to verify the extra credit button behavior #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Snaptags, could you update your branch to the latest? This test changed quite a bit. Also, I'm not sure what these changes do to help. Could you elaborate?
...xtra credit requirements
e55e048 to
ec50666
Compare
Sorry, did not upgrade my fork first 😞
The test gives a deceptive feeling of safety when starting the extra credit 1 exercise: If you just apply the changes suggested by the instructions, the test immediately is green again. Because, accidentally, replacing the state by the step (1 in this case) is a valid result.
const [count, changeCount] = React.useReducer(countReducer, initialCount) const increment = () => changeCount(step)
But people have to change the reducer implementation, too. By clicking the increase button twice the test makes sure that you don't mess up the reducer while refactoring. And to make sure you actually can increase the counter more than once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes total sense. Thank you!
@all-contributors please add @Snaptags for tests
I've put up a pull request to add @Snaptags! 🎉
It might be nice to verify the button actually increases the existing value. If you start to implement the extra credit requirements you might accidentally set the count to "step". Then the test would still be green, it only fails when you try to click the button again...