[SSF-52] jest tests for pantries controller/service files#55
[SSF-52] jest tests for pantries controller/service files#55swarkewalia merged 20 commits intomainfrom
Conversation
Juwang110
left a comment
There was a problem hiding this comment.
Overall structure looks good! requires some refactoring though based on comments and using jest-mock-extended
| }); | ||
|
|
||
| // Get pantries with pending status | ||
| describe('getPendingPantries', () => { |
There was a problem hiding this comment.
Add a pantry that is not pending to assert this only gets pending ones
There was a problem hiding this comment.
On second glance I don't think this is possible/easy since we are relying on repository filtering logic with "where", so this test is fine
…k/SSF-52-backend-pantries-tests
…/Code-4-Community/ssf into sk/SSF-52-backend-pantries-tests
| import { mock } from 'jest-mock-extended'; | ||
| import { PantryApplicationDto } from './dtos/pantry-application.dto'; | ||
|
|
||
| jest.mock('../utils/validation.utils', () => ({ |
There was a problem hiding this comment.
Since validateId is a basic utils function that doesn't rely on the database, we shouldn't have to mock it in tests
Leaving the below here as a note for the future - don't worry about doing this now since service tests will have to be updated later to use the mock database
Also, for the service functions that call validateId, can we check that calling them with an ID that causes (the real implementation of) validateId to throw an error also causes the service function to error?
…k/SSF-52-backend-pantries-tests
…/Code-4-Community/ssf into sk/SSF-52-backend-pantries-tests
ℹ️ Issue SSF-52
Closes https://vidushimisra.atlassian.net/browse/SSF-52
📝 Description
Added jest tests to the backend for /pantries, specifically for pantries.controller.ts and pantries.service.ts.
✔️ Verification
Ensured all tests are passing