Commit 2392bae6 authored by Jeremy M Fee's avatar Jeremy M Fee Committed by Edward J Hunter
Browse files

Add tests, correct units

parent ae54be25
......@@ -3,10 +3,10 @@ import { DistanceAzimuthPipe } from './distance-azimuth.pipe';
describe('DistanceAzimuthPipe', () => {
let pipe;
let place;
let referencePlace;
beforeEach(() => {
pipe = new DistanceAzimuthPipe();
place = {
admin1_code: 'NM',
admin1_name: 'New Mexico',
......@@ -22,6 +22,10 @@ describe('DistanceAzimuthPipe', () => {
name: 'Vegas Junction',
population: 0
};
referencePlace = {
latitude: 39,
longitude: -105
};
});
describe('compassWinds', () => {
......@@ -38,4 +42,15 @@ describe('DistanceAzimuthPipe', () => {
expect(pipe.compassWinds(522.7)).toEqual('SSE');
});
});
describe('transform', () => {
it('should accept a place', () => {
expect(pipe.transform(place)).toEqual('2.7 km (1.7 mi) SSE');
});
it('should accept a referencePlace', () => {
expect(pipe.transform(place, referencePlace)).toEqual(
'447.3 km (277.9 mi) N'
);
});
});
});
......@@ -3,7 +3,9 @@ import * as calculator from 'azimuth';
import { Place } from './place';
export interface DistanceAzimuth {
// decimal degrees
azimuth: number;
// kilometers
distance: number;
}
......@@ -28,7 +30,7 @@ export function getDistanceAzimuth(
}
);
azimuth = distAz.azimuth;
distance = distAz.distance;
distance = distAz.distance / 1000; // meters to kilometers
}
return {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment