import { describe, it, expect } from 'vitest';
import { evaluateEdgeSwipe } from './useEdgeSwipe';

const opts = { edgeWidth: 20, openThreshold: 60, verticalTolerance: 40 };

describe('evaluateEdgeSwipe', () => {
  it('opens when starting at left edge and dragging right past threshold', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: 80, y: 100 }, opts)).toBe('open');
  });

  it('does nothing when starting outside the edge band', () => {
    expect(evaluateEdgeSwipe({ x: 50, y: 100 }, { x: 200, y: 100 }, opts)).toBeNull();
  });

  it('does nothing when horizontal travel is below threshold', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: 50, y: 100 }, opts)).toBeNull();
  });

  it('opens when horizontal travel is exactly at threshold', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: 65, y: 100 }, opts)).toBe('open');
  });

  it('does nothing when vertical drift exceeds tolerance (treated as scroll)', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: 80, y: 160 }, opts)).toBeNull();
  });

  it('does nothing when user drags leftward from edge', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: -200, y: 100 }, opts)).toBeNull();
  });

  it('does nothing when end exactly equals start', () => {
    expect(evaluateEdgeSwipe({ x: 5, y: 100 }, { x: 5, y: 100 }, opts)).toBeNull();
  });
});
