-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from ddarren/ds-test-coverage
- Loading branch information
Showing
9 changed files
with
160 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import findNearest from './findNearest'; | ||
|
||
describe('findNearest', () => { | ||
it('returns first result from orderByDistance', () => { | ||
const point = { latitude: 51.516241842, longitude: 7.456494328 }; | ||
const nearest = { latitude: 51.515400598, longitude: 7.45518541 }; | ||
const coords = [ | ||
{ latitude: 51.513357512, longitude: 7.45574331 }, | ||
nearest, | ||
{ latitude: 51.516722545, longitude: 7.459863183 }, | ||
{ latitude: 51.517443592, longitude: 7.463232037 }, | ||
]; | ||
|
||
expect(findNearest(point, coords)).toEqual(nearest); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import getRoughCompassDirection from './getRoughCompassDirection'; | ||
|
||
describe('getRoughCompassDirection', () => { | ||
describe('when exact compass direction is Northern', () => { | ||
it('returns N', () => { | ||
['NNE', 'NE', 'NNW', 'N'].forEach((exactCompassDirection) => { | ||
expect(getRoughCompassDirection(exactCompassDirection)).toEqual( | ||
'N' | ||
); | ||
}); | ||
}); | ||
}); | ||
describe('when exact compass direction is Eastern', () => { | ||
it('returns E', () => { | ||
['ENE', 'E', 'ESE', 'SE'].forEach((exactCompassDirection) => { | ||
expect(getRoughCompassDirection(exactCompassDirection)).toEqual( | ||
'E' | ||
); | ||
}); | ||
}); | ||
}); | ||
describe('when exact compass direction is Southern', () => { | ||
it('returns S', () => { | ||
['SSE', 'S', 'SSW', 'SW'].forEach((exactCompassDirection) => { | ||
expect(getRoughCompassDirection(exactCompassDirection)).toEqual( | ||
'S' | ||
); | ||
}); | ||
}); | ||
}); | ||
describe('when exact compass direction is Western', () => { | ||
it('returns W', () => { | ||
['WSW', 'W', 'WNW', 'NW'].forEach((exactCompassDirection) => { | ||
expect(getRoughCompassDirection(exactCompassDirection)).toEqual( | ||
'W' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import isValidLatitude from './isValidLatitude'; | ||
import { MAXLAT, MINLAT } from './constants'; | ||
|
||
describe('isValidLatitude', () => { | ||
describe('when value is a decimal', () => { | ||
describe('when value is between MINLAT and MAXLAT', () => { | ||
it('returns true', () => { | ||
let value = MAXLAT - 1; | ||
expect(isValidLatitude(value)).toEqual(true); | ||
value = MINLAT + 1; | ||
expect(isValidLatitude(value)).toEqual(true); | ||
}); | ||
}); | ||
describe('when value is not between MINLAT and MAXLAT', () => { | ||
it('returns false', () => { | ||
let value = MAXLAT + 1; | ||
expect(isValidLatitude(value)).toEqual(false); | ||
value = MINLAT - 1; | ||
expect(isValidLatitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
describe('when value is a sexagesimal', () => { | ||
describe('when value is between MINLAT and MAXLAT', () => { | ||
it('returns true', () => { | ||
const value = '51° 31\' 10.11" N'; | ||
expect(isValidLatitude(value)).toEqual(true); | ||
}); | ||
}); | ||
describe('when value is not between MINLAT and MAXLAT', () => { | ||
it('returns false', () => { | ||
const value = '121°26′31″W'; | ||
expect(isValidLatitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
describe('when value is not a decimal or sexagesimal', () => { | ||
it('returns false', () => { | ||
const value = 'foo'; | ||
expect(isValidLatitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import isValidLongitude from './isValidLongitude'; | ||
import { MAXLON, MINLON } from './constants'; | ||
|
||
describe('isValidLongitude', () => { | ||
describe('when value is a decimal', () => { | ||
describe('when value is between MINLON and MAXLON', () => { | ||
it('returns true', () => { | ||
let value = MAXLON - 1; | ||
expect(isValidLongitude(value)).toEqual(true); | ||
value = MINLON + 1; | ||
expect(isValidLongitude(value)).toEqual(true); | ||
}); | ||
}); | ||
describe('when value is not between MINLON and MAXLON', () => { | ||
it('returns false', () => { | ||
let value = MAXLON + 1; | ||
expect(isValidLongitude(value)).toEqual(false); | ||
value = MINLON - 1; | ||
expect(isValidLongitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
describe('when value is a sexagesimal', () => { | ||
describe('when value is between MINLON and MAXLON', () => { | ||
it('returns true', () => { | ||
const value = '51° 31\' 10.11" N'; | ||
expect(isValidLongitude(value)).toEqual(true); | ||
}); | ||
}); | ||
describe('when value is not between MINLON and MAXLON', () => { | ||
it('returns false', () => { | ||
const value = '221°26′31″W'; | ||
expect(isValidLongitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); | ||
describe('when value is not a decimal or sexagesimal', () => { | ||
it('returns false', () => { | ||
const value = 'foo'; | ||
expect(isValidLongitude(value)).toEqual(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import toDeg from './toDeg'; | ||
|
||
describe('toDeg', () => { | ||
it('converts a value to a degree', () => { | ||
expect(toDeg(35.238965)).toEqual(2019.0439689092252); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import toRad from './toRad'; | ||
|
||
describe('toRad', () => { | ||
it('converts a value to a radian', () => { | ||
expect(toRad(2019.0439689092252)).toEqual(35.238965); | ||
}); | ||
}); |