mediaPreview.test.ts 1.0 KB

12345678910111213141516171819202122232425262728
  1. import { describe, expect, it } from "vitest";
  2. import { getMediaPreviewFormat } from "@zcode/shared";
  3. describe("media preview formats", () => {
  4. it.each([
  5. ["clip.mp4", "video", "video/mp4"],
  6. ["clip.mov", "video", "video/quicktime"],
  7. ["clip.webm", "video", "video/webm"],
  8. ["clip.m4v", "video", "video/x-m4v"],
  9. ["song.mp3", "audio", "audio/mpeg"],
  10. ["song.wav", "audio", "audio/wav"],
  11. ["song.m4a", "audio", "audio/mp4"],
  12. ["song.ogg", "audio", "audio/ogg"],
  13. ["song.opus", "audio", "audio/opus"],
  14. ["song.flac", "audio", "audio/flac"],
  15. ["song.weba", "audio", "audio/webm"],
  16. ])("resolves %s", (path, kind, mediaType) => {
  17. expect(getMediaPreviewFormat(path)).toMatchObject({ kind, mediaType });
  18. });
  19. it("normalizes Windows separators and rejects unsupported containers", () => {
  20. expect(getMediaPreviewFormat("dist\\demo\\clip.MP4")).toMatchObject({
  21. kind: "video",
  22. mediaType: "video/mp4",
  23. });
  24. expect(getMediaPreviewFormat("clip.mkv")).toBeNull();
  25. });
  26. });