fix tests ugh
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 5m53s

This commit is contained in:
2025-12-09 18:48:17 -08:00
parent 4674309ea1
commit 23e0c44b61
10 changed files with 89 additions and 79 deletions

View File

@@ -246,9 +246,10 @@ describe('Admin Content Management Routes (/api/admin)', () => {
});
it('PUT /comments/:id/status should return 400 for an invalid status', async () => {
// Mock the database call to prevent it from executing. The route should validate
// the status and return 400 before the DB is ever touched.
vi.mocked(mockedDb.adminRepo.updateRecipeCommentStatus).mockRejectedValue(new Error('This should not be called'));
// For this test, we do NOT mock the database call. The route handler should
// validate the 'status' from the request body and return a 400 Bad Request
// *before* any database interaction is attempted. If the mock were called,
// it would indicate a logic error in the route.
const response = await supertest(app).put('/api/admin/comments/301').send({ status: 'invalid-status' });
expect(response.status).toBe(400);
expect(response.body.message).toContain('A valid status');