Spaces:
Running
Running
| 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 }); | |
| }); | |
| }); | |