Skip to content

Commit b7d6876

Browse files
test(Label_20_POS): validate preamble, parsed coordinates, and formatted POS item
Co-Authored-By: Kevin Elliott <kevin@welikeinc.com>
1 parent d3270d5 commit b7d6876

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lib/plugins/Label_20_POS.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,39 @@ describe('Label_20_POS', () => {
1414
const res = decode(text);
1515

1616
expect(res.decoded).toBe(true);
17+
expect(res.decoder.name).toBe('label-20-pos');
1718
expect(res.decoder.decodeLevel).toBe('full');
1819
expect(res.formatted.description).toBe('Position Report');
20+
1921
expect(res.raw.preamble).toBe('POS');
22+
expect(res.raw.position).toBeDefined();
23+
expect(res.raw.position.latitude).toBeCloseTo(38.160, 3);
24+
expect(res.raw.position.longitude).toBeCloseTo(-77.075, 3);
25+
26+
const posItem = res.formatted.items.find(i => i.code === 'POS');
27+
expect(posItem).toBeDefined();
28+
expect(posItem.value).toContain('38.160');
29+
expect(posItem.value).toContain('77.075');
2030
});
2131

2232
it('decodes POS variation with 5 fields (coordinates only)', () => {
2333
const text = 'POSN38160W077075,,211733,360,OTT';
2434
const res = decode(text);
2535

2636
expect(res.decoded).toBe(true);
37+
expect(res.decoder.name).toBe('label-20-pos');
2738
expect(res.decoder.decodeLevel).toBe('full');
2839
expect(res.formatted.description).toBe('Position Report');
40+
41+
expect(res.raw.preamble).toBe('POS');
42+
expect(res.raw.position).toBeDefined();
43+
expect(res.raw.position.latitude).toBeCloseTo(38.160, 3);
44+
expect(res.raw.position.longitude).toBeCloseTo(-77.075, 3);
45+
46+
const posItem = res.formatted.items.find(i => i.code === 'POS');
47+
expect(posItem).toBeDefined();
48+
expect(posItem.value).toContain('38.160');
49+
expect(posItem.value).toContain('77.075');
2950
});
3051

3152
it('marks unknown variation as not decoded', () => {

0 commit comments

Comments
 (0)