2026-04-01 19:27:49 +02:00
|
|
|
import { describe, expect, test } from "bun:test";
|
|
|
|
|
import {
|
|
|
|
|
getHighestImportedVideoFps,
|
|
|
|
|
getRaisedProjectFpsForImportedMedia,
|
|
|
|
|
} from "@/lib/fps/utils";
|
|
|
|
|
|
|
|
|
|
describe("getHighestImportedVideoFps", () => {
|
|
|
|
|
test("returns the highest valid video fps", () => {
|
|
|
|
|
expect(
|
|
|
|
|
getHighestImportedVideoFps({
|
|
|
|
|
mediaAssets: [
|
|
|
|
|
{ type: "audio" },
|
|
|
|
|
{ type: "video", fps: 30 },
|
|
|
|
|
{ type: "image", fps: 120 },
|
|
|
|
|
{ type: "video", fps: 60 },
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
).toBe(60);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("ignores missing and invalid fps values", () => {
|
|
|
|
|
expect(
|
|
|
|
|
getHighestImportedVideoFps({
|
|
|
|
|
mediaAssets: [
|
|
|
|
|
{ type: "video" },
|
|
|
|
|
{ type: "video", fps: 0 },
|
|
|
|
|
{ type: "video", fps: -10 },
|
|
|
|
|
{ type: "audio", fps: 120 },
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("getRaisedProjectFpsForImportedMedia", () => {
|
|
|
|
|
test("raises the project fps to match a higher-fps import", () => {
|
|
|
|
|
expect(
|
|
|
|
|
getRaisedProjectFpsForImportedMedia({
|
|
|
|
|
currentFps: 30,
|
|
|
|
|
importedAssets: [{ type: "video", fps: 60 }],
|
|
|
|
|
}),
|
|
|
|
|
).toBe(60);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("does not lower the project fps for lower-fps imports", () => {
|
|
|
|
|
expect(
|
|
|
|
|
getRaisedProjectFpsForImportedMedia({
|
|
|
|
|
currentFps: 60,
|
|
|
|
|
importedAssets: [{ type: "video", fps: 10 }],
|
|
|
|
|
}),
|
|
|
|
|
).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("ignores non-video imports", () => {
|
|
|
|
|
expect(
|
|
|
|
|
getRaisedProjectFpsForImportedMedia({
|
|
|
|
|
currentFps: 30,
|
|
|
|
|
importedAssets: [
|
|
|
|
|
{ type: "image", fps: 60 },
|
|
|
|
|
{ type: "audio", fps: 120 },
|
|
|
|
|
],
|
|
|
|
|
}),
|
|
|
|
|
).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|