From 26f9880264cac1d335d43fa728eceed5794fec18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Sun, 17 May 2026 00:34:58 +0200 Subject: [PATCH] test: update toJson mock factories for doctor-report-prefs + healthkit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The v1.4.34.3 code-quality batch added a `toJson()` helper in `src/lib/db.ts` to consolidate the seven Prisma JSON-cast sites. Two existing route tests mock the entire `@/lib/db` module via `vi.mock` — those mock factories now need to expose the new export so the route's import resolves to a real function under test. The mock implementation is the identity cast (`(v: T) => v`), which matches what production does and keeps the test's JSON-payload assertions stable. --- src/app/api/auth/me/doctor-report-prefs/__tests__/route.test.ts | 1 + src/app/api/integrations/healthkit/__tests__/route.test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/app/api/auth/me/doctor-report-prefs/__tests__/route.test.ts b/src/app/api/auth/me/doctor-report-prefs/__tests__/route.test.ts index 13e2159ab..10b0aea2d 100644 --- a/src/app/api/auth/me/doctor-report-prefs/__tests__/route.test.ts +++ b/src/app/api/auth/me/doctor-report-prefs/__tests__/route.test.ts @@ -7,6 +7,7 @@ vi.mock("@/lib/db", () => ({ update: vi.fn(), }, }, + toJson: (v: T) => v, })); vi.mock("@/lib/auth/session", () => ({ getSession: vi.fn() })); diff --git a/src/app/api/integrations/healthkit/__tests__/route.test.ts b/src/app/api/integrations/healthkit/__tests__/route.test.ts index 41d4c980a..f31ecf4bb 100644 --- a/src/app/api/integrations/healthkit/__tests__/route.test.ts +++ b/src/app/api/integrations/healthkit/__tests__/route.test.ts @@ -5,6 +5,7 @@ vi.mock("@/lib/db", () => ({ prisma: { user: { findUnique: vi.fn(), update: vi.fn() }, }, + toJson: (v: T) => v, })); vi.mock("@/lib/auth/session", () => ({ getSession: vi.fn() }));