21 lines
668 B
TypeScript
21 lines
668 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { haversineKm } from './geo';
|
|
|
|
describe('haversineKm', () => {
|
|
it('returns 0 for identical points', () => {
|
|
expect(haversineKm(50.03, 8.57, 50.03, 8.57)).toBeCloseTo(0, 10);
|
|
});
|
|
|
|
it('computes the London → Paris great-circle distance (~343 km)', () => {
|
|
const km = haversineKm(51.47, -0.454, 49.0097, 2.5479); // LHR → CDG
|
|
expect(km).toBeGreaterThan(330);
|
|
expect(km).toBeLessThan(360);
|
|
});
|
|
|
|
it('is symmetric', () => {
|
|
const a = haversineKm(50.03, 8.57, 40.47, -3.56); // FRA → MAD
|
|
const b = haversineKm(40.47, -3.56, 50.03, 8.57);
|
|
expect(a).toBeCloseTo(b, 10);
|
|
});
|
|
});
|