import { expect, test } from "@playwright/test"; import { DEFAULT_VIDEO_CROP_RECT, getVideoCropOutputDimensions, moveVideoCropRect, normalizeVideoCropRect, resizeVideoCropRect, } from "../../lib/video-canvas/video-crop"; test.describe("video canvas crop tools", () => { test("defaults to the competitor eighty-percent crop", () => { expect(normalizeVideoCropRect(undefined)).toEqual(DEFAULT_VIDEO_CROP_RECT); expect(getVideoCropOutputDimensions(DEFAULT_VIDEO_CROP_RECT, 1280, 720)).toEqual({ width: 1024, height: 576, }); }); test("moves the crop without leaving the source", () => { expect(moveVideoCropRect(DEFAULT_VIDEO_CROP_RECT, 0.5, -0.5)).toEqual({ x: 0.2, y: 0, width: 0.8, height: 0.8, }); }); test("resizes all axes freely with a nonzero minimum", () => { expect(resizeVideoCropRect(DEFAULT_VIDEO_CROP_RECT, "e", 1, 0.5)).toEqual({ x: 0.1, y: 0.1, width: 0.9, height: 0.8, }); expect(resizeVideoCropRect(DEFAULT_VIDEO_CROP_RECT, "nw", 0.95, 0.95)).toEqual({ x: 0.85, y: 0.85, width: 0.05, height: 0.05, }); }); });