From 41cd36fe6cfa11b081d1b82df63abe4302142eaa Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 22:29:04 +0100 Subject: [PATCH] test: guard media fetch call --- src/media/fetch.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/media/fetch.test.ts b/src/media/fetch.test.ts index 3b620642938..5c5010d64b8 100644 --- a/src/media/fetch.test.ts +++ b/src/media/fetch.test.ts @@ -45,6 +45,14 @@ function makeLookupFn(): LookupFn { return vi.fn(async () => ({ address: "149.154.167.220", family: 4 })) as unknown as LookupFn; } +function requireFetchGuardRequest(): unknown { + const [call] = fetchWithSsrFGuardMock.mock.calls; + if (!call) { + throw new Error("expected fetchWithSsrFGuard call"); + } + return call[0]; +} + async function expectRemoteMediaMaxBytesError(params: { fetchImpl: Parameters[0]["fetchImpl"]; maxBytes: number; @@ -342,7 +350,7 @@ describe("fetchRemoteMedia", () => { }); expect(fetchWithSsrFGuardMock).toHaveBeenCalledTimes(1); - expect(fetchWithSsrFGuardMock.mock.calls[0]?.[0]).toStrictEqual({ + expect(requireFetchGuardRequest()).toStrictEqual({ url: "https://files.example.test/file/bot123/photos/test.jpg", fetchImpl, init: undefined,