import { describe, it, expect } from 'vitest';
import { snapZoom, ZOOM_SNAP_THRESHOLD, INERTIA_MIN_SPEED } from '../gestures/useInertia';

describe('useInertia', () => {
	describe('snapZoom', () => {
		it('snaps to 1.0 when within threshold', () => {
			expect(snapZoom(1.0)).toBe(1.0);
			expect(snapZoom(1.0 + ZOOM_SNAP_THRESHOLD * 0.5)).toBe(1.0);
			expect(snapZoom(1.0 - ZOOM_SNAP_THRESHOLD * 0.5)).toBe(1.0);
		});

		it('does not snap when outside threshold', () => {
			const above = 1.0 + ZOOM_SNAP_THRESHOLD + 0.01;
			expect(snapZoom(above)).toBe(above);

			const below = 1.0 - ZOOM_SNAP_THRESHOLD - 0.01;
			expect(snapZoom(below)).toBe(below);
		});

		it('passes through values far from 1.0', () => {
			expect(snapZoom(0.5)).toBe(0.5);
			expect(snapZoom(2.0)).toBe(2.0);
			expect(snapZoom(0.1)).toBe(0.1);
			expect(snapZoom(5.0)).toBe(5.0);
		});
	});

	describe('constants', () => {
		it('ZOOM_SNAP_THRESHOLD is a small positive number', () => {
			expect(ZOOM_SNAP_THRESHOLD).toBeGreaterThan(0);
			expect(ZOOM_SNAP_THRESHOLD).toBeLessThan(0.1);
		});

		it('INERTIA_MIN_SPEED is a positive number', () => {
			expect(INERTIA_MIN_SPEED).toBeGreaterThan(0);
		});
	});
});
