From e320524c6394272f41980f276222f803b6137b09 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 17 May 2024 14:37:01 +0100 Subject: [PATCH] Test case. --- .../src/integrations/tests/restUtils.spec.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/tests/restUtils.spec.ts b/packages/server/src/integrations/tests/restUtils.spec.ts index cdcaaec489..b26bd14c44 100644 --- a/packages/server/src/integrations/tests/restUtils.spec.ts +++ b/packages/server/src/integrations/tests/restUtils.spec.ts @@ -1,13 +1,13 @@ import { getAttachmentHeaders } from "../utils/restUtils" import type { Headers } from "node-fetch" -function headers(dispositionValue: string) { +function headers(dispositionValue: string, contentType?: string) { return { get: (name: string) => { if (name.toLowerCase() === "content-disposition") { return dispositionValue } else { - return "application/pdf" + return contentType || "application/pdf" } }, set: () => {}, @@ -35,4 +35,14 @@ describe("getAttachmentHeaders", () => { ) expect(contentDisposition).toBe(`inline; filename="report.pdf"`) }) + + it("should handle an image", () => { + const { contentDisposition } = getAttachmentHeaders( + headers("", "image/png"), + { + downloadImages: true, + } + ) + expect(contentDisposition).toBe(`attachment; filename="image.png"`) + }) })