import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { classifySwipe } from './useSwipeNav'; const start = { x: 300, y: 200, t: 1_000 }; const at = (x: number, y: number) => ({ x, y }); describe('classifySwipe', () => { it('left is next, right is prev', () => { assert.equal(classifySwipe(start, at(100, 210), 1_200), 'next'); assert.equal(classifySwipe({ ...start, x: 100 }, at(300, 190), 1_200), 'prev'); }); it('ignores short, too-vertical and too-slow gestures', () => { assert.equal(classifySwipe(start, at(260, 200), 1_200), undefined); assert.equal(classifySwipe(start, at(100, 400), 1_200), undefined); assert.equal(classifySwipe(start, at(100, 200), 2_500), undefined); }); it('allows a little vertical drift on a long horizontal swipe', () => { assert.equal(classifySwipe(start, at(60, 340), 1_300), 'next'); }); });