From d5a048f518324faa1e99df9e0ae9bc240184c053 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 9 Oct 2023 18:32:45 +1100 Subject: [PATCH] chore: add further tests (#625) --- e2e_test.ts | 12 ++++++++++++ utils/db_test.ts | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/e2e_test.ts b/e2e_test.ts index a352fd7bc..90c9cd32c 100644 --- a/e2e_test.ts +++ b/e2e_test.ts @@ -437,6 +437,18 @@ Deno.test("[e2e] POST /api/vote", async (test) => { assertEquals(resp.status, Status.Created); }); + + await test.step("serves an error response if the `item_id` URL parameter is missing", async () => { + const resp = await handler( + new Request("http://localhost/api/vote", { + method: "POST", + headers: { cookie: "site-session=" + user.sessionId }, + }), + ); + + assertEquals(resp.status, Status.BadRequest); + assertEquals(await resp.text(), "`item_id` URL parameter missing"); + }); }); function createStripeEvent( diff --git a/utils/db_test.ts b/utils/db_test.ts index 914e8bec6..18596577d 100644 --- a/utils/db_test.ts +++ b/utils/db_test.ts @@ -85,6 +85,12 @@ Deno.test("[db] user", async () => { ...user, sessionId: newSessionId, }); + + await assertRejects( + async () => await updateUserSession(user, newSessionId), + Error, + "Failed to update user session", + ); }); Deno.test("[db] votes", async () => {