Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { fitVideoFrame } from "./videoFrameFit";
4
5describe("fitVideoFrame", () => {
6 const bounds = { width: 360, height: 600 };
7
8 it("keeps landscape videos at the full capped width", () => {
9 expect(fitVideoFrame({ width: 1920, height: 1080 }, bounds, 480)).toEqual({
10 width: 360,
11 height: 202.5,
12 });
13 });
14
15 it("limits portrait videos by the available height", () => {
16 expect(fitVideoFrame({ width: 1080, height: 1920 }, bounds, 480)).toEqual({
17 width: 337.5,
18 height: 600,
19 });
20 });
21
22 it("caps wide bounds at the inline width", () => {
23 expect(fitVideoFrame({ width: 1080, height: 1080 }, { width: 800, height: 900 }, 480)).toEqual({
24 width: 480,
25 height: 480,
26 });
27 });
28
29 it("returns null before the video or bounds have a size", () => {
30 expect(fitVideoFrame({ width: 0, height: 0 }, bounds, 480)).toBeNull();
31 expect(fitVideoFrame({ width: 1080, height: 1920 }, { width: 0, height: 0 }, 480)).toBeNull();
32 });
33});