1import { describe, expect, it } from "vite-plus/test";
2
3import { videoMimeType } from "./video.ts";
4
5describe("videoMimeType", () => {
6 it("recognizes a saved video with a generic picker MIME type", () => {
7 expect(videoMimeType({ name: "Recording.MOV", mimeType: "application/octet-stream" })).toBe(
8 "video/quicktime",
9 );
10 });
11
12 it("keeps an explicit video MIME type authoritative and removes parameters", () => {
13 expect(videoMimeType({ name: "recording.mp4", mimeType: " VIDEO/WebM; codecs=vp9 " })).toBe(
14 "video/webm",
15 );
16 });
17
18 it.each(["README", "report.pdf", "file.constructor", "file.__proto__"])(
19 "does not mistake %s for a video",
20 (name) => {
21 expect(videoMimeType({ name, mimeType: "application/octet-stream" })).toBeNull();
22 },
23 );
24
25 it("keeps a declared non-video MIME type instead of inferring from the extension", () => {
26 expect(videoMimeType({ name: "recording.mp4", mimeType: "application/pdf" })).toBeNull();
27 expect(videoMimeType({ name: "recording.mp4", mimeType: "image/png" })).toBeNull();
28 });
29});