@@ -121,6 +121,16 @@ function firstRespondCall(respond: ReturnType<typeof vi.fn>): RespondCall | unde
|
121 | 121 | return respond.mock.calls[0] as RespondCall | undefined; |
122 | 122 | } |
123 | 123 | |
| 124 | +function expectSuccessfulPushTestResponse(respond: ReturnType<typeof vi.fn>): ApnsPushResult { |
| 125 | +expect(sendApnsAlert).toHaveBeenCalledTimes(1); |
| 126 | +const call = firstRespondCall(respond); |
| 127 | +expect(call?.[0]).toBe(true); |
| 128 | +const result = call?.[1] as ApnsPushResult | undefined; |
| 129 | +expect(result?.ok).toBe(true); |
| 130 | +expect(result?.status).toBe(200); |
| 131 | +return result as ApnsPushResult; |
| 132 | +} |
| 133 | + |
124 | 134 | describe("push.test handler", () => { |
125 | 135 | beforeEach(() => { |
126 | 136 | mocks.getRuntimeConfig.mockClear(); |
@@ -160,12 +170,7 @@ describe("push.test handler", () => {
|
160 | 170 | }); |
161 | 171 | await invoke(); |
162 | 172 | |
163 | | -expect(sendApnsAlert).toHaveBeenCalledTimes(1); |
164 | | -const call = firstRespondCall(respond); |
165 | | -expect(call?.[0]).toBe(true); |
166 | | -const result = call?.[1] as ApnsPushResult | undefined; |
167 | | -expect(result?.ok).toBe(true); |
168 | | -expect(result?.status).toBe(200); |
| 173 | +expectSuccessfulPushTestResponse(respond); |
169 | 174 | }); |
170 | 175 | |
171 | 176 | it("sends push test through relay registrations", async () => { |
@@ -223,12 +228,7 @@ describe("push.test handler", () => {
|
223 | 228 | }, |
224 | 229 | { registrationRelayOrigin: undefined }, |
225 | 230 | ); |
226 | | -expect(sendApnsAlert).toHaveBeenCalledTimes(1); |
227 | | -const call = firstRespondCall(respond); |
228 | | -expect(call?.[0]).toBe(true); |
229 | | -const result = call?.[1] as ApnsPushResult | undefined; |
230 | | -expect(result?.ok).toBe(true); |
231 | | -expect(result?.status).toBe(200); |
| 231 | +const result = expectSuccessfulPushTestResponse(respond); |
232 | 232 | expect(result?.transport).toBe("relay"); |
233 | 233 | }); |
234 | 234 | |
|