From 278b6d9e3ccd9e1b28b9b605661d834df68b91f1 Mon Sep 17 00:00:00 2001 From: Isjuanplayer Date: Tue, 9 Jun 2026 02:53:05 +0200 Subject: [PATCH] test: await ky create request --- tests/routes/things/create.test.ts | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/routes/things/create.test.ts b/tests/routes/things/create.test.ts index 65e9935..73f51fb 100644 --- a/tests/routes/things/create.test.ts +++ b/tests/routes/things/create.test.ts @@ -4,16 +4,26 @@ import { test, expect } from "bun:test" test("create a thing", async () => { const { ky } = await getTestServer() - ky.post("things/create", { - json: { + const createData = await ky + .post("things/create", { + json: { + name: "Thing1", + description: "Thing1 Description", + }, + }) + .json<{ ok: boolean }>() + + expect(createData.ok).toBe(true) + + const data = await ky.get("things/list").json<{ + things: { thing_id: string; name: string; description: string }[] + }>() + + expect(data.things).toEqual([ + { + thing_id: expect.any(String), name: "Thing1", description: "Thing1 Description", }, - }) - - const data = await ky - .get("things/list") - .json<{ things: { name: string; description: string }[] }>() - - expect(data.things).toHaveLength(1) + ]) })