summaryrefslogtreecommitdiff
path: root/apps/web/src/lib/project/__tests__
diff options
context:
space:
mode:
authorMaze Winther <mazewinther@gmail.com>2026-03-27 00:55:15 +0100
committerMaze Winther <mazewinther@gmail.com>2026-03-29 15:56:48 +0200
commit4d127a038bf768eded68aae3cfa5c1b12241bdac (patch)
tree16bbb801caf6770546cff4fdb37b6408ec9ead98 /apps/web/src/lib/project/__tests__
parent82817cb50cb0487350573d6129130aec705f924b (diff)
downloadopencut-4d127a038bf768eded68aae3cfa5c1b12241bdac.tar.gz
chore: normalize line endings
Diffstat (limited to 'apps/web/src/lib/project/__tests__')
-rw-r--r--apps/web/src/lib/project/__tests__/fps.test.ts65
1 files changed, 65 insertions, 0 deletions
diff --git a/apps/web/src/lib/project/__tests__/fps.test.ts b/apps/web/src/lib/project/__tests__/fps.test.ts
new file mode 100644
index 00000000..b30408ef
--- /dev/null
+++ b/apps/web/src/lib/project/__tests__/fps.test.ts
@@ -0,0 +1,65 @@
+import { describe, expect, test } from "bun:test";
+import {
+ getHighestImportedVideoFps,
+ getRaisedProjectFpsForImportedMedia,
+} from "@/lib/project/fps";
+
+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();
+ });
+});