Skip to content

Conversation

@jng34
Copy link
Member

@jng34 jng34 commented May 3, 2025

Fixes #1893

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

  • Wrote unit tests for questions.router

Screenshots of Passed Tests

image

@JackHaeg JackHaeg requested a review from dannyprikaz May 15, 2025 22:45
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.

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.

Copy link
Member Author

@jng34 jng34 left a 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.

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.

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!

@dannyprikaz dannyprikaz merged commit 095b24a into hackforla:development Jun 24, 2025
2 of 4 checks passed
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/questions.router.js

2 participants