File size: 1,005 Bytes
7142bcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { describe, expect, it } from 'vitest';
import {
  resolveSidebarDrag,
  SIDEBAR_COLLAPSE_THRESHOLD,
  SIDEBAR_EXPAND_THRESHOLD,
} from './BonsaiShell';

describe('sidebar drag snapping', () => {
  it('snaps an open sidebar closed at the collapse threshold', () => {
    expect(resolveSidebarDrag(SIDEBAR_COLLAPSE_THRESHOLD, true, 520)).toEqual({
      open: false,
      width: 0,
    });
  });

  it('stays closed inside the hysteresis band', () => {
    expect(resolveSidebarDrag(SIDEBAR_EXPAND_THRESHOLD - 1, false, 520)).toEqual({
      open: false,
      width: 0,
    });
  });

  it('reopens during the same drag once the pointer crosses the expand threshold', () => {
    expect(resolveSidebarDrag(SIDEBAR_EXPAND_THRESHOLD, false, 520)).toEqual({
      open: true,
      width: SIDEBAR_EXPAND_THRESHOLD,
    });
  });

  it('caps a dragged sidebar so the chat keeps its reserved width', () => {
    expect(resolveSidebarDrag(900, true, 460)).toEqual({ open: true, width: 460 });
  });
});