test(server): apply simplify pass — drop redundant Effect.gen, prose comments, and assertion casts
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
/**
|
||||
* Regression: a schema rejection used to come back as `400` with an empty
|
||||
* body, leaving the renderer / SDK / curl with no way to tell which field
|
||||
* failed. The schemaErrorLayer now returns a NamedError-shaped JSON body
|
||||
* (same shape as 404 NotFoundError) so callers see the actual reason.
|
||||
*/
|
||||
import { afterEach, describe, expect } from "bun:test"
|
||||
import { Effect } from "effect"
|
||||
import { Server } from "../../src/server/server"
|
||||
@@ -26,9 +20,6 @@ describe("schema-rejection wire shape", () => {
|
||||
).pipe(
|
||||
Effect.flatMap((tmp) =>
|
||||
Effect.gen(function* () {
|
||||
// POST /sync/history with `aggregate: -1` is an invalid Body shape
|
||||
// (aggregate is a NamedString) and triggers the framework's
|
||||
// HttpApiSchemaError on the Body kind.
|
||||
const res = yield* Effect.promise(async () =>
|
||||
Server.Default().app.request(SyncPaths.history, {
|
||||
method: "POST",
|
||||
@@ -39,11 +30,13 @@ describe("schema-rejection wire shape", () => {
|
||||
const body = yield* Effect.promise(async () => res.text())
|
||||
expect(res.status).toBe(400)
|
||||
expect(res.headers.get("content-type") ?? "").toContain("application/json")
|
||||
const parsed = JSON.parse(body) as { name?: string; data?: { message?: string; kind?: string } }
|
||||
expect(parsed.name).toBe("BadRequest")
|
||||
expect(typeof parsed.data?.message).toBe("string")
|
||||
expect(parsed.data?.message?.length ?? 0).toBeGreaterThan(0)
|
||||
expect(parsed.data?.kind).toMatch(/^(Body|Payload)$/)
|
||||
const parsed = JSON.parse(body)
|
||||
expect(parsed).toMatchObject({
|
||||
name: "BadRequest",
|
||||
data: { kind: expect.stringMatching(/^(Body|Payload)$/) },
|
||||
})
|
||||
expect(parsed.data.message).toEqual(expect.any(String))
|
||||
expect(parsed.data.message.length).toBeGreaterThan(0)
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user