Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

test(frontend): cover MIME precedence in non-PDF type detection (#6438)

Saul Ifshindd24440b73c1
diff --git a/frontend/editor/src/core/utils/fileUtils.test.ts b/frontend/editor/src/core/utils/fileUtils.test.ts
index 8b1a1afd95..fcdb539264 100644
--- a/frontend/editor/src/core/utils/fileUtils.test.ts
+++ b/frontend/editor/src/core/utils/fileUtils.test.ts
@@ -3,6 +3,7 @@ import {
isPdfFile,
detectFileExtension,
formatFileSize,
+ detectNonPdfFileType,
} from "@app/utils/fileUtils";
describe("fileUtils", () => {
@@ -94,4 +95,18 @@ describe("fileUtils", () => {
expect(formatFileSize(1024 * 1024 * 1024)).toBe("1 GB");
});
});
+
+ describe("detectNonPdfFileType", () => {
+ it("should prioritize MIME type over extension when they conflict", () => {
+ expect(
+ detectNonPdfFileType({
+ name: "financial-summary.pdf",
+ type: "text/csv",
+ }),
+ ).toBe("csv");
+ expect(
+ detectNonPdfFileType({ name: "diagram.png", type: "application/json" }),
+ ).toBe("json");
+ });
+ });
});