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);