Download packages/app/src/pages/session/message-gesture.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/pages/session/message-gesture.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/pages/session/message-gesture.test.ts
-
curl -L -o message-gesture.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/pages/session/message-gesture.test.ts
1.61 kB
| import { describe, expect, test } from "bun:test" | |
| import { normalizeWheelDelta, shouldMarkBoundaryGesture } from "./message-gesture" | |
| describe("normalizeWheelDelta", () => { | |
| test("converts line mode to px", () => { | |
| expect(normalizeWheelDelta({ deltaY: 3, deltaMode: 1, rootHeight: 500 })).toBe(120) | |
| }) | |
| test("converts page mode to container height", () => { | |
| expect(normalizeWheelDelta({ deltaY: -1, deltaMode: 2, rootHeight: 600 })).toBe(-600) | |
| }) | |
| test("keeps pixel mode unchanged", () => { | |
| expect(normalizeWheelDelta({ deltaY: 16, deltaMode: 0, rootHeight: 600 })).toBe(16) | |
| }) | |
| }) | |
| describe("shouldMarkBoundaryGesture", () => { | |
| test("marks when nested scroller cannot scroll", () => { | |
| expect( | |
| shouldMarkBoundaryGesture({ | |
| delta: 20, | |
| scrollTop: 0, | |
| scrollHeight: 300, | |
| clientHeight: 300, | |
| }), | |
| ).toBe(true) | |
| }) | |
| test("marks when scrolling beyond top boundary", () => { | |
| expect( | |
| shouldMarkBoundaryGesture({ | |
| delta: -40, | |
| scrollTop: 10, | |
| scrollHeight: 1000, | |
| clientHeight: 400, | |
| }), | |
| ).toBe(true) | |
| }) | |
| test("marks when scrolling beyond bottom boundary", () => { | |
| expect( | |
| shouldMarkBoundaryGesture({ | |
| delta: 50, | |
| scrollTop: 580, | |
| scrollHeight: 1000, | |
| clientHeight: 400, | |
| }), | |
| ).toBe(true) | |
| }) | |
| test("does not mark when nested scroller can consume movement", () => { | |
| expect( | |
| shouldMarkBoundaryGesture({ | |
| delta: 20, | |
| scrollTop: 200, | |
| scrollHeight: 1000, | |
| clientHeight: 400, | |
| }), | |
| ).toBe(false) | |
| }) | |
| }) | |