-
-
Notifications
You must be signed in to change notification settings - Fork 97
Unit testing for Questions router #1913
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
Unit testing for Questions router #1913
Conversation
dannyprikaz
left a comment
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.
Hey, James. These tests look good for the success scenarios,, but like we discussed with Angela last week, when the logic we are testing has failing scenarios, we should add tests for those as well. I included an example in my comments.
jng34
left a comment
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.
@dannyprikaz
Added testing for all fail cases.
dannyprikaz
left a comment
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.
Hey, @jng34 . This all looks good to me. As a note for the future, I think this code could be a little DRYer. This applies to the last PR I approved as well, for the recurring events. We could define a constant for mockDatabaseError or something like that up top. Then we could use that as the mockRejectedValue for Question.find and Question.create. That would save a couple of lines. More impactful, I think we could define consoleLogSpy up top and then move consoleLogSpy.mockRestore() to the afterEach block, if that mockRestore call isn't already covered by jest.clearAllMocks()
Something to think about!
Fixes #1893
What changes did you make and why did you make them ?
questions.routerScreenshots of Passed Tests