Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/utils/files/uploadFileClient.mime.test.ts
T

22 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { resolveUploadMimeType } from "./uploadFileClient";
describe("resolveUploadMimeType", () => {
it("keeps what the browser reports", () => {
expect(resolveUploadMimeType({ name: "angebot.pdf", type: "application/pdf" })).toBe("application/pdf");
});
it("falls back to the extension when the browser reports nothing", () => {
// macOS has no system type for .md, so Chrome hands over an empty string —
// declaring octet-stream there got a file the store allows rejected.
expect(resolveUploadMimeType({ name: "notiz.md", type: "" })).toBe("text/markdown");
expect(resolveUploadMimeType({ name: "Notiz.MARKDOWN", type: "" })).toBe("text/markdown");
expect(resolveUploadMimeType({ name: "liste.csv", type: "" })).toBe("text/csv");
});
it("stays at octet-stream for anything the store would not take anyway", () => {
expect(resolveUploadMimeType({ name: "tool.exe", type: "" })).toBe("application/octet-stream");
expect(resolveUploadMimeType({ name: "ohne-endung", type: "" })).toBe("application/octet-stream");
});
});