-
-
Notifications
You must be signed in to change notification settings - Fork 91
Unit Testing for CheckIns Router #1906
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 CheckIns Router #1906
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.
Hey, @jng34
Great work on this. Nice job in particular with mocking the populate
method on the response to User.findById
in the test for findEvent/:id
. Just two little issues:
- I think the way you're describing the behavior of
/api/checkins/findEvent/:id
is incorrect. Based on my reading of the code (checkins.router.js
lines 30-24), this endpoint finds all of the checkins whoseeventId
field match the id passed in the url. Then they populate those documents with with the corresponding users by theuserId
field. So what this endpoint should really return is "a list of users who have checked in to a specified event." I went hunting through the client to see where this endpoint is used, and it's only ever called fromProjectLeaderDashboard.jsx
, which you worked on in issue #1713 . At that time @trillium said that this component is unused. So all in all, the stakes are low for having a super good test on this endpoint, but I think we should correct the description of what it returns and there seem to be some unneeded complexities to the test you wrote. I put more specific comments for those. - In the create test, it would be ideal if we could make sure
Checkin.create
is actually called withnewCheckin
and not that it's just called at all. I know that my PR does the same thing. I should figure out a way to fix that. It seems to be a slightly different issue when the request is being passed to a controller, but in this case, configuring body parser middleware seems to be the solution. See my comments on the code.
I'm learning a lot as I go through this, so again, I just want to say great work.
Hey @dannyprikaz, Thank you for thoroughly reviewing the PR and for the detailed feedback. You are correct in the description for the All changes have been made. As always, I appreciate the guidance. |
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.
Please see updated changes.
@dannyprikaz Can you please review the updates from @jng34 on this PR and potentially approve when you have a moment this week? |
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.
Looks good! thanks
Fixes #1886
What changes did you make and why did you make them ?
checkIns.router.js
that isolate the behavior of the router from its dependenciesScreenshot of passed tests