Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 resizeBrowserViewportFromRail,
5 resolveFittedBrowserViewport,
6} from "./browserViewportLayout";
7
8describe("resolveBrowserViewportLayout", () => {
9 it("preserves the last logical viewport when fitting a fill-mode surface", () => {
10 expect(
11 resolveFittedBrowserViewport({ _tag: "fill" }, { width: 320, height: 200, scale: 0.25 }),
12 ).toEqual({ _tag: "freeform", width: 1280, height: 800 });
13 });
14
15 it("keeps the grabbed rail under the pointer across centered layout boundaries", () => {
16 const available = { width: 1120, height: 818 };
17 expect(
18 resizeBrowserViewportFromRail(
19 { width: 1120, height: 818 },
20 { x: -100, y: -50 },
21 available,
22 1,
23 "southeast",
24 ),
25 ).toEqual({ width: 920, height: 718 });
26 expect(
27 resizeBrowserViewportFromRail(
28 { width: 800, height: 600 },
29 { x: 300, y: 0 },
30 { width: 1200, height: 800 },
31 1,
32 "east",
33 ),
34 ).toEqual({ width: 1300, height: 600 });
35 expect(
36 resizeBrowserViewportFromRail(
37 { width: 560, height: 409 },
38 { x: -100, y: 0 },
39 available,
40 2,
41 "east",
42 ),
43 ).toEqual({ width: 460, height: 409 });
44 });
45});