test: dedupe discord forwarded media assertions

This commit is contained in:
Peter Steinberger 2026-03-13 22:26:24 +00:00
parent cad1c95405
commit 3eb039c554
1 changed files with 5 additions and 22 deletions

View File

@ -173,30 +173,13 @@ describe("resolveForwardedMediaList", () => {
512,
);
expect(fetchRemoteMedia).toHaveBeenCalledTimes(1);
const call = fetchRemoteMedia.mock.calls[0]?.[0] as {
url?: string;
filePathHint?: string;
maxBytes?: number;
fetchImpl?: unknown;
ssrfPolicy?: unknown;
};
expect(call).toMatchObject({
url: attachment.url,
expectSinglePngDownload({
result,
expectedUrl: attachment.url,
filePathHint: attachment.filename,
maxBytes: 512,
fetchImpl: undefined,
expectedPath: "/tmp/image.png",
placeholder: "<media:image>",
});
expectDiscordCdnSsrFPolicy(call.ssrfPolicy);
expect(saveMediaBuffer).toHaveBeenCalledTimes(1);
expect(saveMediaBuffer).toHaveBeenCalledWith(expect.any(Buffer), "image/png", "inbound", 512);
expect(result).toEqual([
{
path: "/tmp/image.png",
contentType: "image/png",
placeholder: "<media:image>",
},
]);
});
it("forwards fetchImpl to forwarded attachment downloads", async () => {