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

threadSidebarWidth.test.ts

34 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import {
4 resolveInitialThreadSidebarWidth,
5 THREAD_MAIN_CONTENT_MIN_WIDTH,
6 THREAD_SIDEBAR_DEFAULT_WIDTH,
7 THREAD_SIDEBAR_MIN_WIDTH,
8} from "./threadSidebarWidth";
9​
10describe("thread sidebar width", () => {
11 it("uses the default width when no preference is stored", () => {
12 expect(resolveInitialThreadSidebarWidth(null, 1200)).toBe(THREAD_SIDEBAR_DEFAULT_WIDTH);
13 });
14​
15 it("uses a stored width in the initial render", () => {
16 expect(resolveInitialThreadSidebarWidth(360, 1200)).toBe(360);
17 });
18​
19 it("clamps a stored width to the sidebar minimum", () => {
20 expect(resolveInitialThreadSidebarWidth(120, 1200)).toBe(THREAD_SIDEBAR_MIN_WIDTH);
21 });
22​
23 it("leaves enough room for the main content on a smaller window", () => {
24 const viewportWidth = 1000;
25​
26 expect(resolveInitialThreadSidebarWidth(900, viewportWidth)).toBe(
27 viewportWidth - THREAD_MAIN_CONTENT_MIN_WIDTH,
28 );
29 });
30​
31 it("keeps the sidebar minimum when the whole layout is narrower than its minimums", () => {
32 expect(resolveInitialThreadSidebarWidth(900, 700)).toBe(THREAD_SIDEBAR_MIN_WIDTH);
33 });
34});