Team Ai
Apppublic

WaveCut/Bonsai-Chat-WebGPU

sourceHugging Faceupdated 3mo agoView on Hugging Face
5likes
BonsaiShell.test.ts34 linesDownload Raw Back to components
1import { describe, expect, it } from 'vitest';2import {3  resolveSidebarDrag,4  SIDEBAR_COLLAPSE_THRESHOLD,5  SIDEBAR_EXPAND_THRESHOLD,6} from './BonsaiShell';7 8describe('sidebar drag snapping', () => {9  it('snaps an open sidebar closed at the collapse threshold', () => {10    expect(resolveSidebarDrag(SIDEBAR_COLLAPSE_THRESHOLD, true, 520)).toEqual({11      open: false,12      width: 0,13    });14  });15 16  it('stays closed inside the hysteresis band', () => {17    expect(resolveSidebarDrag(SIDEBAR_EXPAND_THRESHOLD - 1, false, 520)).toEqual({18      open: false,19      width: 0,20    });21  });22 23  it('reopens during the same drag once the pointer crosses the expand threshold', () => {24    expect(resolveSidebarDrag(SIDEBAR_EXPAND_THRESHOLD, false, 520)).toEqual({25      open: true,26      width: SIDEBAR_EXPAND_THRESHOLD,27    });28  });29 30  it('caps a dragged sidebar so the chat keeps its reserved width', () => {31    expect(resolveSidebarDrag(900, true, 460)).toEqual({ open: true, width: 460 });32  });33});34