Skip to content

Conversation

angela-lee1
Copy link
Member

@angela-lee1 angela-lee1 commented Jun 9, 2025

Fixes #1888

What changes did you make and why did you make them ?

  • write unit tests for each route on ./backend/routers/events.router.js
Screenshot 2025-06-08 at 9 33 46 PM

Copy link
Member

@dannyprikaz dannyprikaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(() => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write some comments for this and other sections


const response = await request.get(`/api/events/nexteventbyproject/${mockProjectId}`);

expect(Event.find).toHaveBeenCalledWith({ project: mockProjectId });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need these conditions that are tested in the last test case.

@JackHaeg
Copy link
Member

Update - @angela-lee1 will be updating this PR over the course of this week

@angela-lee1
Copy link
Member Author

Terribly sorry about the delay. I'll get it completed by tonight or tomorrow night. No blockers.

@angela-lee1
Copy link
Member Author

Screenshot 2025-07-12 at 4 45 08 PM 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.

Copy link
Member

@dannyprikaz dannyprikaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create New Unit Tests for ./backend/routers/events.router.js

4 participants