Files
edr-platform/apps/edr-freight-api/src/common/mile-distance.util.spec.ts

18 lines
534 B
TypeScript

import { haversineKm } from './mile-distance.util';
describe('haversineKm', () => {
it('is zero for the same point', () => {
expect(haversineKm(8.9, 38.6, 8.9, 38.6)).toBe(0);
});
it('matches one degree of longitude at the equator (~111.19 km)', () => {
expect(haversineKm(0, 0, 0, 1)).toBeCloseTo(111.19, 1);
});
it('Sebeta yard → Indode yard is roughly 26 km', () => {
const km = haversineKm(8.9096, 38.636, 8.7386, 38.7913);
expect(km).toBeGreaterThan(20);
expect(km).toBeLessThan(35);
});
});