From ae9b7041ef8ba2fbad993688e6eb20daf3d97034 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 12 May 2026 22:33:51 +0100 Subject: [PATCH] test: dedupe gateway push mock reads --- src/gateway/server-methods/push.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/gateway/server-methods/push.test.ts b/src/gateway/server-methods/push.test.ts index 2f0b0832e38..d39c7380eda 100644 --- a/src/gateway/server-methods/push.test.ts +++ b/src/gateway/server-methods/push.test.ts @@ -111,12 +111,16 @@ function expectInvalidRequestResponse( respond: ReturnType, expectedMessagePart: string, ) { - const call = respond.mock.calls.at(0) as RespondCall | undefined; + const call = firstRespondCall(respond); expect(call?.[0]).toBe(false); expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST); expect(call?.[2]?.message).toContain(expectedMessagePart); } +function firstRespondCall(respond: ReturnType): RespondCall | undefined { + return respond.mock.calls[0] as RespondCall | undefined; +} + describe("push.test handler", () => { beforeEach(() => { mocks.getRuntimeConfig.mockClear(); @@ -157,7 +161,7 @@ describe("push.test handler", () => { await invoke(); expect(sendApnsAlert).toHaveBeenCalledTimes(1); - const call = respond.mock.calls.at(0) as RespondCall | undefined; + const call = firstRespondCall(respond); expect(call?.[0]).toBe(true); const result = call?.[1] as ApnsPushResult | undefined; expect(result?.ok).toBe(true); @@ -216,7 +220,7 @@ describe("push.test handler", () => { }, }); expect(sendApnsAlert).toHaveBeenCalledTimes(1); - const call = respond.mock.calls.at(0) as RespondCall | undefined; + const call = firstRespondCall(respond); expect(call?.[0]).toBe(true); const result = call?.[1] as ApnsPushResult | undefined; expect(result?.ok).toBe(true);