diff options
| author | Pawel Zelawski <pawel@pzelawski.com> | 2026-10-04 16:51:18 +0200 |
|---|---|---|
| committer | Pawel Zelawski <pawel@pzelawski.com> | 2026-10-04 16:51:18 +0200 |
| commit | 1ea071717b046584216a8501917eb3720c19ea0b (patch) | |
| tree | 762208aa2e8f8347edf8be192fd79e6cb7163822 /tests/server/main.test.ts | |
| parent | 93287b442971957e56233b5c2e927ae57bd7ba57 (diff) | |
- 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.
Diffstat (limited to 'tests/server/main.test.ts')
| -rw-r--r-- | tests/server/main.test.ts | 29 |
1 files changed, 29 insertions, 0 deletions
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'); + }); }); |
