From 1ea071717b046584216a8501917eb3720c19ea0b Mon Sep 17 00:00:00 2001 From: Pawel Zelawski Date: Sun, 4 Oct 2026 16:51:18 +0200 Subject: test: cover uncovered functions to meet coverage thresholds - Server: root health route and malformed-JSON error middleware - Client: status polling and start error paths where the error body is not JSON Function coverage rises from 68.42% to 89.47%, satisfying the 70% gate. --- tests/server/main.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/server/main.test.ts') diff --git a/tests/server/main.test.ts b/tests/server/main.test.ts index 0a5aee3..225a450 100644 --- a/tests/server/main.test.ts +++ b/tests/server/main.test.ts @@ -189,4 +189,33 @@ describe('server api', () => { expect(status.statusCode).toBe(404); expect(statusBody.status).toBe('not_found'); }); + + it('serves a health message on the root route', async () => { + const app = createApp({ + publicUrl: 'http://localhost:3001', + nodeEnv: 'test', + }); + + const response = await inject(app, { method: 'GET', url: '/' }); + + expect(response.statusCode).toBe(200); + expect(response.body).toContain('DigiID Demo Backend Running!'); + }); + + it('returns 500 when the request body is malformed JSON', async () => { + const app = createApp({ + publicUrl: 'http://localhost:3001', + nodeEnv: 'test', + }); + + const response = await inject(app, { + method: 'POST', + url: '/api/digiid/callback', + headers: { 'content-type': 'application/json' }, + payload: '{"address": ', + }); + + expect(response.statusCode).toBe(500); + expect(response.json().error).toBe('Internal server error'); + }); }); -- cgit v1.2.3