test: dedupe apns relay mock reads · openclaw/openclaw@c6ebc1d
steipete
·
2026-05-13
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -54,6 +54,10 @@ function expectRelayConfig(
|
54 | 54 | expect(resolved.value.timeoutMs).toBe(expected.timeoutMs); |
55 | 55 | } |
56 | 56 | |
| 57 | +function firstMockCall<T extends unknown[]>(mock: { mock: { calls: T[] } }): T | undefined { |
| 58 | +return mock.mock.calls[0]; |
| 59 | +} |
| 60 | + |
57 | 61 | describe("push-apns.relay", () => { |
58 | 62 | describe("resolveApnsRelayConfigFromEnv", () => { |
59 | 63 | it("returns a missing-config error when no relay base URL is configured", () => { |
@@ -160,7 +164,7 @@ describe("push-apns.relay", () => {
|
160 | 164 | }); |
161 | 165 | |
162 | 166 | expect(sender).toHaveBeenCalledTimes(1); |
163 | | -const sent = sender.mock.calls.at(0)?.[0] as |
| 167 | +const sent = firstMockCall(sender)?.[0] as |
164 | 168 | | { |
165 | 169 | relayConfig?: { baseUrl?: string; timeoutMs?: number }; |
166 | 170 | sendGrant?: string; |
@@ -221,7 +225,7 @@ describe("push-apns.relay", () => {
|
221 | 225 | const result = await sendApnsRelayPush(createRelayPushParams()); |
222 | 226 | |
223 | 227 | expect(fetchMock).toHaveBeenCalledTimes(1); |
224 | | -const fetchOptions = fetchMock.mock.calls.at(0)?.[1] as { redirect?: unknown } | undefined; |
| 228 | +const fetchOptions = firstMockCall(fetchMock)?.[1] as { redirect?: unknown } | undefined; |
225 | 229 | expect(fetchOptions?.redirect).toBe("manual"); |
226 | 230 | expect(result.ok).toBe(false); |
227 | 231 | expect(result.status).toBe(302); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。