Added the Haversine distance algoritm

This commit is contained in:
Carlos Carvalho
2020-10-06 18:15:20 -03:00
parent 0dfb200e64
commit ca4509478e
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import { haversineDistance } from './Haversine'
describe('Testing the haversine distance calculator', () => {
it('Calculate distance', () => {
const distance = haversineDistance(64.1265, -21.8174, 40.7128, -74.0060)
expect(distance).toBe(4208198.758424171)
})
it('Test validation, expect throw', () => {
expect(() => haversineDistance(64.1265, -21.8174, 40.7128, '74.0060')).toThrow()
})
})