Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

saveToMediaLibrary.test.ts

20 lines732 Bytes

1import { expect, it, vi } from "vite-plus/test";
2​
3const native = vi.hoisted(() => ({ saveToMediaLibrary: vi.fn(async () => {}) }));
4​
5vi.mock("expo", () => ({ requireNativeModule: () => native }));
6vi.mock("react-native", () => ({ Platform: { OS: "android", Version: 34 } }));
7​
8import { mediaLibraryKind, saveToMediaLibrary } from "./saveToMediaLibrary";
9​
10it("hands the native module a lowercase MIME type, which picks the gallery folder", async () => {
11 expect(mediaLibraryKind("Video/MP4")).toBe("video");
12​
13 await saveToMediaLibrary("file:///cache/clip.mp4", "Video/MP4; codecs=avc1", "clip.mp4");
14​
15 expect(native.saveToMediaLibrary).toHaveBeenCalledWith(
16 "file:///cache/clip.mp4",
17 "video/mp4",
18 "clip.mp4",
19 );
20});