Skip to content

Commit

Permalink
test: add additional test cases for DmsUnsignedDelimitedSuffixedHemis…
Browse files Browse the repository at this point in the history
…phereFormat
  • Loading branch information
reskume committed Dec 5, 2024
1 parent 903377c commit e7467ce
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DmsUnsignedDelimitedSuffixedHemisphereFormat } from '../src/formats/dms
describe('canParse', () => {
it('returns true for known formats', () => {
expect(DmsUnsignedDelimitedSuffixedHemisphereFormat.canParse(`40:7:23N 74:7:23W`)).toBe(true);
expect(DmsUnsignedDelimitedSuffixedHemisphereFormat.canParse(`35:02:15 N 131:59:23 E`)).toBe(true);
expect(DmsUnsignedDelimitedSuffixedHemisphereFormat.canParse(`40:7:23N74:7:23W`)).toBe(true);
expect(DmsUnsignedDelimitedSuffixedHemisphereFormat.canParse(`40:7:23N, 74:7:23W`)).toBe(true);
expect(DmsUnsignedDelimitedSuffixedHemisphereFormat.canParse(`40:7:23N,74:7:23W`)).toBe(true);
Expand All @@ -18,6 +19,13 @@ describe('parse', () => {
expect(result.longitude).toBe(-74.12306);
});

it(`returns the correct latitude and longitude for 35:02:15 N 131:59:23 E`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`35:02:15 N 131:59:23 E`);
expect(result.latitude).toBe(35.0375);
expect(result.longitude).toBe(131.98972);
});

it(`returns the correct latitude and longitude for 40:7:23N74:7:23W`, () => {
const formatParser = new DmsUnsignedDelimitedSuffixedHemisphereFormat();
const result = formatParser.parse(`40:7:23N74:7:23W`);
Expand Down

0 comments on commit e7467ce

Please sign in to comment.