From ee0f7208df2ddd2e0c359f07fab2dc24e74fdf11 Mon Sep 17 00:00:00 2001 From: KGFCH2 Date: Wed, 27 May 2026 03:42:01 +0530 Subject: [PATCH] test: assert response codes on invalid JSON formats and empty requests --- test/server.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/server.test.js b/test/server.test.js index 9e3e546..001edc5 100644 --- a/test/server.test.js +++ b/test/server.test.js @@ -120,3 +120,18 @@ test("retries transient fetch failures before succeeding", async () => { assert.equal(result.status, 200); assert.equal(attempts, 3); }); + +test("returns 400 for missing URL", async () => { + const app = createApp({ + apiKey: "test-key", + allowedOrigins: ["http://localhost:3000"], + fetchImpl: async () => ({ + ok: true, + json: async () => ({}) + }) + }); + + const result = await runRequest(app, {}, "http://localhost:3000"); + assert.equal(result.status, 400); + assert.equal(result.body.error, "No URL provided"); +});