Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

threadSidebarWidth.test.ts

31 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 clampThreadSidebarWidth,
5 resolveInitialThreadSidebarWidth,
6 resolveThreadSidebarMaximumWidth,
7 resolveThreadSidebarMinimumWidth,
8} from "./threadSidebarWidth";
9​
10function renderedWidth(sidebarWidth: number, viewportWidth: number): number {
11 const minimumWidth = resolveThreadSidebarMinimumWidth(0);
12 return clampThreadSidebarWidth(
13 sidebarWidth,
14 minimumWidth,
15 resolveThreadSidebarMaximumWidth(viewportWidth, minimumWidth),
16 );
18​
19describe("thread sidebar width", () => {
20 it("restores the stored width when the viewport widens after a narrow startup", () => {
21 const sidebarWidth = resolveInitialThreadSidebarWidth(350);
22 expect(renderedWidth(sidebarWidth, 840)).toBe(208);
23 expect(renderedWidth(sidebarWidth, 1638)).toBe(350);
24 });
25​
26 it("restores the default width when the viewport widens after a narrow startup", () => {
27 const sidebarWidth = resolveInitialThreadSidebarWidth(null);
28 expect(renderedWidth(sidebarWidth, 840)).toBe(208);
29 expect(renderedWidth(sidebarWidth, 1638)).toBe(256);
30 });
31});