diff --git a/src/plugins/wired-hooks-inbound-claim.test.ts b/src/plugins/wired-hooks-inbound-claim.test.ts index f67caacba6d..eeb0664600d 100644 --- a/src/plugins/wired-hooks-inbound-claim.test.ts +++ b/src/plugins/wired-hooks-inbound-claim.test.ts @@ -33,6 +33,18 @@ function createInboundClaimForumCtx() { }; } +function expectFirstErrorLog( + logger: { error: ReturnType }, + expected: readonly unknown[], +): void { + expect(logger.error).toHaveBeenCalledTimes(1); + const call = logger.error.mock.calls.at(0); + if (!call) { + throw new Error("expected logger.error call"); + } + expect(call).toEqual(expected); +} + describe("inbound_claim hook runner", () => { it("stops at the first handler that claims the event", async () => { const first = vi.fn().mockResolvedValue({ handled: true }); @@ -81,10 +93,7 @@ describe("inbound_claim hook runner", () => { ); expect(result).toEqual({ handled: true }); - expect(logger.error).toHaveBeenCalledTimes(1); - expect(logger.error.mock.calls[0]).toEqual([ - "[hooks] inbound_claim handler from test-plugin failed: boom", - ]); + expectFirstErrorLog(logger, ["[hooks] inbound_claim handler from test-plugin failed: boom"]); expect(succeeding).toHaveBeenCalledTimes(1); }); @@ -194,8 +203,7 @@ describe("inbound_claim hook runner", () => { await vi.advanceTimersByTimeAsync(5); await expect(run).resolves.toEqual({ status: "error", error: "timed out after 5ms" }); - expect(logger.error).toHaveBeenCalledTimes(1); - expect(logger.error.mock.calls[0]).toEqual([ + expectFirstErrorLog(logger, [ "[hooks] inbound_claim handler from test-plugin failed: timed out after 5ms", ]); } finally {