add test for events routers#1956
Conversation
dannyprikaz
left a comment
There was a problem hiding this comment.
This test module works great. It would just be nice to have some more comments to explain how everything works and then remove a few unneeded items.
| it('should call EventController.create and return the created event', async (done) => { | ||
| EventController.create.mockImplementationOnce((req, res) => res.status(201).send(mockEvent)); | ||
|
|
||
| const newEventData = { |
There was a problem hiding this comment.
Don't really need this object. We could just reuse. mockEvent
| it('should return 500 if an error occurs when fetching next event by project', async (done) => { | ||
| const mockError = new Error('Simulated database error for next event by project'); | ||
|
|
||
| Event.find.mockImplementationOnce(() => ({ |
There was a problem hiding this comment.
Please write some comments for this and other sections
There was a problem hiding this comment.
Don't need these conditions that are tested in the last test case.
|
Update - @angela-lee1 will be updating this PR over the course of this week |
|
Terribly sorry about the delay. I'll get it completed by tonight or tomorrow night. No blockers. |
Hey @dannyprikaz @trillium , terribly sorry about the delay. I am quite free this weekend. Should any updates be needed, please feel free to send a message in Slack.
|
jng34
left a comment
There was a problem hiding this comment.
@angela-lee1 Just nit-picking and re-iterating the comments that Danny left regarding comments and clean-up of code moving forward, but all tests have passed!
trillium
left a comment
There was a problem hiding this comment.
Review: Approve
Summary: Adds unit tests for Events router with comprehensive CRUD coverage.
Tests (16/16 passing)
events.router.test.js (7 tests)
- ✅ GET /api/events
- ✅ POST /api/events
- ✅ GET /api/events/:id
- ✅ DELETE /api/events/:id
- ✅ PATCH /api/events/:id
- ✅ GET /api/events/nexteventbyproject/:id (+ error case)
recurringEvents.router.test.js (9 tests)
- ✅ CRUD operations + error handling
Rebased onto upstream/development. Ready to merge.

Fixes #1888
What changes did you make and why did you make them ?