test: Cover bad request responses for API endpoint tests

This commit is contained in:
Faruk AYDIN
2024-02-26 13:30:30 +01:00
parent 404ea94dd2
commit d74b215169
6 changed files with 74 additions and 17 deletions

View File

@@ -33,14 +33,23 @@ describe('GET /api/v1/admin/users/:userId', () => {
expect(response.body).toEqual(expectedPayload);
});
it('should return not found response for not existing user ID', async () => {
it('should return not found response for not existing user UUID', async () => {
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
const invalidUserId = Crypto.randomUUID();
const notExistingUserUUID = Crypto.randomUUID();
await request(app)
.get(`/api/v1/admin/users/${invalidUserId}`)
.get(`/api/v1/admin/users/${notExistingUserUUID}`)
.set('Authorization', token)
.expect(404);
});
it('should return bad request response for invalid UUID', async () => {
vi.spyOn(license, 'hasValidLicense').mockResolvedValue(true);
await request(app)
.get('/api/v1/admin/users/invalidUserUUID')
.set('Authorization', token)
.expect(400);
});
});