From 54a852aa82c3be0b63731cba643802cb91f46e73 Mon Sep 17 00:00:00 2001 From: snkk2x-collab Date: Thu, 18 Jun 2026 23:27:16 +0800 Subject: [PATCH] test: await ky create request --- tests/routes/things/create.test.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/routes/things/create.test.ts b/tests/routes/things/create.test.ts index 65e9935..f4d26c8 100644 --- a/tests/routes/things/create.test.ts +++ b/tests/routes/things/create.test.ts @@ -4,16 +4,24 @@ import { test, expect } from "bun:test" test("create a thing", async () => { const { ky } = await getTestServer() - ky.post("things/create", { - json: { - name: "Thing1", - description: "Thing1 Description", - }, - }) + const createData = await ky + .post("things/create", { + json: { + name: "Thing1", + description: "Thing1 Description", + }, + }) + .json<{ ok: boolean }>() + + expect(createData).toEqual({ ok: true }) const data = await ky .get("things/list") .json<{ things: { name: string; description: string }[] }>() expect(data.things).toHaveLength(1) + expect(data.things[0]).toMatchObject({ + name: "Thing1", + description: "Thing1 Description", + }) })