@@ -111,12 +111,16 @@ function expectInvalidRequestResponse(
|
111 | 111 | respond: ReturnType<typeof vi.fn>, |
112 | 112 | expectedMessagePart: string, |
113 | 113 | ) { |
114 | | -const call = respond.mock.calls.at(0) as RespondCall | undefined; |
| 114 | +const call = firstRespondCall(respond); |
115 | 115 | expect(call?.[0]).toBe(false); |
116 | 116 | expect(call?.[2]?.code).toBe(ErrorCodes.INVALID_REQUEST); |
117 | 117 | expect(call?.[2]?.message).toContain(expectedMessagePart); |
118 | 118 | } |
119 | 119 | |
| 120 | +function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall | undefined { |
| 121 | +return respond.mock.calls[0] as RespondCall | undefined; |
| 122 | +} |
| 123 | + |
120 | 124 | describe("push.test handler", () => { |
121 | 125 | beforeEach(() => { |
122 | 126 | mocks.getRuntimeConfig.mockClear(); |
@@ -157,7 +161,7 @@ describe("push.test handler", () => {
|
157 | 161 | await invoke(); |
158 | 162 | |
159 | 163 | expect(sendApnsAlert).toHaveBeenCalledTimes(1); |
160 | | -const call = respond.mock.calls.at(0) as RespondCall | undefined; |
| 164 | +const call = firstRespondCall(respond); |
161 | 165 | expect(call?.[0]).toBe(true); |
162 | 166 | const result = call?.[1] as ApnsPushResult | undefined; |
163 | 167 | expect(result?.ok).toBe(true); |
@@ -216,7 +220,7 @@ describe("push.test handler", () => {
|
216 | 220 | }, |
217 | 221 | }); |
218 | 222 | expect(sendApnsAlert).toHaveBeenCalledTimes(1); |
219 | | -const call = respond.mock.calls.at(0) as RespondCall | undefined; |
| 223 | +const call = firstRespondCall(respond); |
220 | 224 | expect(call?.[0]).toBe(true); |
221 | 225 | const result = call?.[1] as ApnsPushResult | undefined; |
222 | 226 | expect(result?.ok).toBe(true); |
|