From 3dd0d7a9738215864a9ad6c97fa7849642cc0723 Mon Sep 17 00:00:00 2001 From: z1551778201-ctrl Date: Wed, 13 May 2026 01:41:13 +0200 Subject: [PATCH] test: cover api route edges Signed-off-by: z1551778201-ctrl --- src/api/index.test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/api/index.test.ts b/src/api/index.test.ts index 8a2f03a..97793c2 100644 --- a/src/api/index.test.ts +++ b/src/api/index.test.ts @@ -17,6 +17,36 @@ describe('API Request Handler', () => { expect(text).toBe('Success') }) + it('should ignore query strings for a valid GET request', async () => { + const request = new Request( + 'https://starbasedb.test.workers.dev/api/your/path/here?source=test', + { + method: 'GET', + } + ) + + const response = await handleApiRequest(request) + + expect(response.status).toBe(200) + const text = await response.text() + expect(text).toBe('Success') + }) + + it('should return 404 when the path has a trailing slash', async () => { + const request = new Request( + 'https://starbasedb.test.workers.dev/api/your/path/here/', + { + method: 'GET', + } + ) + + const response = await handleApiRequest(request) + + expect(response.status).toBe(404) + const text = await response.text() + expect(text).toBe('Not found') + }) + it('should return 404 for an unknown GET request', async () => { const request = new Request( 'https://starbasedb.test.workers.dev/api/unknown',