Files
Mangalord/frontend/src/lib/swipe.test.ts
MechaCat02 3f1a5e9c41 feat(reader): swipe left/right to turn pages in single mode
Wire horizontal swipe into the mobile tap-zone overlay (single mode only,
so continuous mode keeps native vertical scroll). A leftward swipe past the
threshold turns to the next page, rightward to the previous; a mostly-
vertical drag is ignored so panning a tall page never turns it. The gesture
suppresses the synthesized zone tap so it doesn't double-fire. Swipe
classification is a pure, unit-tested helper; e2e drives real touch pointer
events for horizontal (both directions) and vertical cases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-04 21:23:34 +02:00

21 lines
651 B
TypeScript

import { describe, it, expect } from 'vitest';
import { swipeDirection } from './swipe';
describe('swipeDirection', () => {
it('classifies a leftward horizontal swipe as next', () => {
expect(swipeDirection(-100, 8)).toBe('next');
});
it('classifies a rightward horizontal swipe as prev', () => {
expect(swipeDirection(120, -10)).toBe('prev');
});
it('ignores a swipe shorter than the threshold', () => {
expect(swipeDirection(-20, 2)).toBeNull();
});
it('ignores a mostly-vertical drag so panning does not turn the page', () => {
expect(swipeDirection(-50, 90)).toBeNull();
});
});