diff --git a/backend/src/modules/groups/services/groups.service.spec.ts b/backend/src/modules/groups/services/groups.service.spec.ts index 424396f..d30d80d 100644 --- a/backend/src/modules/groups/services/groups.service.spec.ts +++ b/backend/src/modules/groups/services/groups.service.spec.ts @@ -161,7 +161,16 @@ describe('GroupsService', () => { const id = 'nonexistent'; mockDb.select.mockImplementationOnce(() => mockDbOperations); mockDbOperations.from.mockImplementationOnce(() => mockDbOperations); - mockDbOperations.where.mockImplementationOnce(() => [undefined]); + mockDbOperations.where.mockImplementationOnce(() => []); + + await expect(service.findById(id)).rejects.toThrow(NotFoundException); + }); + + it('should throw NotFoundException if there is a database error', async () => { + const id = 'invalid-id'; + mockDb.select.mockImplementationOnce(() => { + throw new Error('Database error'); + }); await expect(service.findById(id)).rejects.toThrow(NotFoundException); });