Files
orca/src/shared/markdown-toc-panel-width.test.ts
T
Jinjing 996284241d Implement resizable Markdown table of contents panel (#5444)
* Implement resizable Markdown table of contents panel

Introduce resizable behavior to the Markdown table of contents panel,
allowing users to adjust its width via a draggable handle.

- Persist the custom panel width in the UI state and main process store.
- Clamp the width to a safe range (200px to 600px) based on layout space.
- Ensure the remaining editor workspace does not shrink below 320px
  by computing constraints dynamically against the parent container width.

* Clone process env without undefined values for Windows preflight

- Filter out undefined values when cloning process.env to prevent
  potential serialization or typing issues.
- Update buildLocalPreflightEnv return type to Record<string, string>.
2026-06-15 19:59:44 -07:00

29 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
MARKDOWN_TOC_PANEL_DEFAULT_WIDTH,
MARKDOWN_TOC_PANEL_MAX_WIDTH,
MARKDOWN_TOC_PANEL_MIN_WIDTH,
clampMarkdownTocPanelWidth,
computeMaxMarkdownTocPanelWidth
} from './markdown-toc-panel-width'
describe('markdown toc panel width', () => {
it('clamps widths into the supported range', () => {
expect(clampMarkdownTocPanelWidth(undefined)).toBe(MARKDOWN_TOC_PANEL_DEFAULT_WIDTH)
expect(clampMarkdownTocPanelWidth(100)).toBe(MARKDOWN_TOC_PANEL_MIN_WIDTH)
expect(clampMarkdownTocPanelWidth(900)).toBe(MARKDOWN_TOC_PANEL_MAX_WIDTH)
})
it('respects the remaining editor width when a container size is known', () => {
expect(computeMaxMarkdownTocPanelWidth(700)).toBe(380)
expect(clampMarkdownTocPanelWidth(500, 700)).toBe(380)
expect(clampMarkdownTocPanelWidth(350, 700)).toBe(350)
})
it('treats the second argument as container width, not a precomputed max', () => {
const maxFor700 = computeMaxMarkdownTocPanelWidth(700)
expect(clampMarkdownTocPanelWidth(350, maxFor700)).toBe(200)
expect(clampMarkdownTocPanelWidth(350, 700)).toBe(350)
})
})