You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
994 B
26 lines
994 B
require('chai').should()
|
|
describe('DistanceResolver', function () {
|
|
const dr = new (require('./DistanceResolver.js'))()
|
|
describe('getDistance should throw exception when', function () {
|
|
it('longitude is out of bounds', function () {
|
|
(() => dr.getDistance([0, 0], [181, 0])).should.throw()
|
|
})
|
|
it('latitude is out of bounds', function () {
|
|
(() => dr.getDistance([0, 0], [180, -91])).should.throw()
|
|
})
|
|
it('invalid strings', function () {
|
|
(() => dr.getDistance(['one hundred', 0], [0, 0])).should.throw()
|
|
})
|
|
it('invalid arrays', function () {
|
|
(() => dr.getDistance([0, 0, 0], [0, 0])).should.throw()
|
|
})
|
|
it('invalid input', function () {
|
|
(() => dr.getDistance('An array', [0, 0])).should.throw()
|
|
})
|
|
})
|
|
|
|
it('_sanitizeCoords should convert string numbers to numbers', function () {
|
|
(() => dr._sanitizeCoords(['1', '-3'])).should.not.throw()
|
|
dr._sanitizeCoords(['1', '-3']).should.have.deep.members([1, -3])
|
|
})
|
|
})
|
|
|