





















@@ -33,6 +33,18 @@ function createInboundClaimForumCtx() {
3333};
3434}
353536+function expectFirstErrorLog(
37+logger: { error: ReturnType<typeof vi.fn> },
38+expected: readonly unknown[],
39+): void {
40+expect(logger.error).toHaveBeenCalledTimes(1);
41+const call = logger.error.mock.calls.at(0);
42+if (!call) {
43+throw new Error("expected logger.error call");
44+}
45+expect(call).toEqual(expected);
46+}
47+3648describe("inbound_claim hook runner", () => {
3749it("stops at the first handler that claims the event", async () => {
3850const first = vi.fn().mockResolvedValue({ handled: true });
@@ -81,10 +93,7 @@ describe("inbound_claim hook runner", () => {
8193);
82948395expect(result).toEqual({ handled: true });
84-expect(logger.error).toHaveBeenCalledTimes(1);
85-expect(logger.error.mock.calls[0]).toEqual([
86-"[hooks] inbound_claim handler from test-plugin failed: boom",
87-]);
96+expectFirstErrorLog(logger, ["[hooks] inbound_claim handler from test-plugin failed: boom"]);
8897expect(succeeding).toHaveBeenCalledTimes(1);
8998});
9099@@ -194,8 +203,7 @@ describe("inbound_claim hook runner", () => {
194203await vi.advanceTimersByTimeAsync(5);
195204196205await expect(run).resolves.toEqual({ status: "error", error: "timed out after 5ms" });
197-expect(logger.error).toHaveBeenCalledTimes(1);
198-expect(logger.error.mock.calls[0]).toEqual([
206+expectFirstErrorLog(logger, [
199207"[hooks] inbound_claim handler from test-plugin failed: timed out after 5ms",
200208]);
201209} finally {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。