1import { describe, expect, it } from "vite-plus/test";
2
3import { isPdfFile } from "./filePreview";
4
5describe("PDF preview detection", () => {
6 it.each([
7 [{ name: "download", mimeType: "application/pdf" }, true],
8 [{ name: "download", mimeType: "APPLICATION/PDF; charset=binary" }, true],
9 [{ name: "Report.PDF", mimeType: "application/octet-stream" }, true],
10 [{ name: "https://example.com/report.pdf?signature=abc#page=2" }, true],
11 [{ name: "report.pdf", mimeType: "text/plain" }, false],
12 [{ name: "report.pdf.exe" }, false],
13 [{ name: "https://example.com/page?download=report.pdf" }, false],
14 ])("classifies %j as %s", (file, expected) => {
15 expect(isPdfFile(file)).toBe(expected);
16 });
17});