chore: refactoring and tests, splitting up files (#12495)

This commit is contained in:
Adam
2026-02-06 10:02:31 -06:00
committed by GitHub
parent a4bc883595
commit 2c58dd6203
117 changed files with 9457 additions and 5827 deletions
@@ -0,0 +1,62 @@
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)
})
})