Skip to content

Commit

Permalink
✅ server: test handling of an unknown error
Browse files Browse the repository at this point in the history
  • Loading branch information
nfmelendez committed Sep 27, 2024
1 parent cb94a65 commit 22c8742
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions server/test/hooks/cryptomate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,24 @@ describe("authorization", () => {
expect(response.status).toBe(200);
await expect(response.json()).resolves.toStrictEqual({ response_code: "51" });
});

it("reports unknown error", async () => {
const captureException = vi.spyOn(sentry, "captureException").mockImplementationOnce(() => "");
const traceCall = vi.spyOn(publicClient, "traceCall");
const unknown = new Error("Unknown");
traceCall.mockImplementationOnce(() => {
throw unknown;
});

const response = await appClient.index.$post({
...authorization,
json: { ...authorization.json, data: { ...authorization.json.data, metadata: { account } } },
});

expect(traceCall).toHaveBeenCalledOnce();
expect(captureException).toHaveBeenCalledOnce();
expect(captureException).toHaveBeenCalledWith(unknown);
expect(response.status).toBe(200);
await expect(response.json()).resolves.toStrictEqual({ response_code: "05" });
});
});

0 comments on commit 22c8742

Please sign in to comment.