1import { describe, expect, it } from "vite-plus/test";
2
3import { getPreviewPanelMaxWidth } from "./PreviewPanelShell";
4
5describe("getPreviewPanelMaxWidth", () => {
6 it("allows the panel to use 70% of an ultra-wide viewport without a pixel ceiling", () => {
7 expect(getPreviewPanelMaxWidth(6_000)).toBe(4_200);
8 });
9
10 it("rounds fractional CSS pixels down", () => {
11 expect(getPreviewPanelMaxWidth(2_001)).toBe(1_400);
12 });
13
14 it("reserves the sibling column minimum when the flex row is known", () => {
15 // Fullscreen 14" MacBook: viewport 1512, sidebar ~256 → row of 1256.
16 // The 70% fraction (1058) would leave the chat column only ~198px;
17 // the container clamp caps the panel at 1256 − 360 instead.
18 expect(getPreviewPanelMaxWidth(1_512, 1_256)).toBe(896);
19 });
20
21 it("keeps the fraction cap when the row is wide enough for both columns", () => {
22 expect(getPreviewPanelMaxWidth(3_000, 2_900)).toBe(2_100);
23 });
24
25 it("rounds fractional row widths down", () => {
26 expect(getPreviewPanelMaxWidth(1_512, 1_256.6)).toBe(896);
27 });
28
29 it("never drops below the panel minimum when the row cannot fit both columns", () => {
30 // ~1000px window with an expanded sidebar → row of 700. The sibling
31 // reservation (700 − 360 = 340) would undercut the panel's own 360
32 // minimum and invert the resize clamp, so the floor wins.
33 expect(getPreviewPanelMaxWidth(1_000, 700)).toBe(360);
34 });
35
36 it("stays at the panel minimum even when the row is narrower than the reservation", () => {
37 expect(getPreviewPanelMaxWidth(1_512, 300)).toBe(360);
38 });
39});