mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
test(documents): satisfy strict null checks on mocked Prisma call args
This commit is contained in:
1 parent
cdd66b6620
commit
02df0d1f0e
2 files changed
+9
-8
No files matched your search
@@ -115,8 +115,8 @@ describe("PATCH /api/documents/inbound/[id]", () => {
|
||||
expect(res.status).toBe(404);
|
||||
expect(prisma.inboundDocument.update).not.toHaveBeenCalled();
|
||||
|
||||
const where = vi.mocked(prisma.inboundDocument.findFirst).mock.calls[0][0]
|
||||
.where;
|
||||
const where = vi.mocked(prisma.inboundDocument.findFirst).mock.calls[0]![0]!
|
||||
.where!;
|
||||
expect(where.userId).toBe("user-1");
|
||||
expect(where.deletedAt).toBeNull();
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ describe("POST /api/documents/inbound (store-only)", () => {
|
||||
expect(body.data.title).toBe("Blood panel");
|
||||
|
||||
// The row is created with status STORED, no provider, userId from session.
|
||||
const arg = vi.mocked(prisma.inboundDocument.create).mock.calls[0][0];
|
||||
const arg = vi.mocked(prisma.inboundDocument.create).mock.calls[0]![0]!;
|
||||
expect(arg.data.status).toBe("STORED");
|
||||
expect(arg.data.userId).toBe("user-1");
|
||||
expect(arg.data.kind).toBe("LAB_RESULT");
|
||||
@@ -169,11 +169,12 @@ describe("GET /api/documents/inbound (list)", () => {
|
||||
expect(body.data.documents).toHaveLength(2);
|
||||
expect(body.data.nextCursor).toBeNull();
|
||||
|
||||
const arg = vi.mocked(prisma.inboundDocument.findMany).mock.calls[0][0];
|
||||
expect(arg.where.userId).toBe("user-1");
|
||||
expect(arg.where.deletedAt).toBeNull();
|
||||
expect(arg.where.kind).toBe("LAB_RESULT");
|
||||
expect(arg.where.OR).toEqual([
|
||||
const arg = vi.mocked(prisma.inboundDocument.findMany).mock.calls[0]![0]!;
|
||||
const where = arg.where!;
|
||||
expect(where.userId).toBe("user-1");
|
||||
expect(where.deletedAt).toBeNull();
|
||||
expect(where.kind).toBe("LAB_RESULT");
|
||||
expect(where.OR).toEqual([
|
||||
{ title: { contains: "panel", mode: "insensitive" } },
|
||||
{ filename: { contains: "panel", mode: "insensitive" } },
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user