import test from 'node:test';
import assert from 'node:assert/strict';

import { detectHorizontalSwipe } from '../src/utils/swipe';

test('detectHorizontalSwipe: 左滑/右滑识别', () => {
  assert.equal(
    detectHorizontalSwipe({ startX: 200, startY: 100, endX: 50, endY: 110, elapsedMs: 200 }),
    'left',
  );
  assert.equal(
    detectHorizontalSwipe({ startX: 50, startY: 100, endX: 200, endY: 90, elapsedMs: 200 }),
    'right',
  );
});

test('detectHorizontalSwipe: 垂直滚动不触发', () => {
  assert.equal(
    detectHorizontalSwipe({ startX: 100, startY: 100, endX: 150, endY: 260, elapsedMs: 200 }),
    null,
  );
});

test('detectHorizontalSwipe: 距离不足不触发', () => {
  assert.equal(
    detectHorizontalSwipe({ startX: 100, startY: 100, endX: 140, endY: 105, elapsedMs: 200 }),
    null,
  );
});

test('detectHorizontalSwipe: 时间过长不触发', () => {
  assert.equal(
    detectHorizontalSwipe({ startX: 200, startY: 100, endX: 50, endY: 110, elapsedMs: 900 }),
    null,
  );
});

