Files
bpq_gui/aprs-packet-text.test.mjs
T
alberto c98c67e18b Add detached service windows and selectable terminal themes
Support standalone APRS, Monitor, Chat and Terminal views with courtesy screens, window focus and return controls, shared sessions and suspended embedded polling.

Add five persistent phosphor palettes, remove Console terminal idle disconnections, and display decoded Mic-E movement and altitude with expandable original packets.

Document the new behavior and add regression coverage. Validation: 182 tests passed; the known hanging PowerShell startup readiness test was excluded.
2026-10-19 22:15:15 +02:00

36 lines
2.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import vm from 'node:vm';
import {readFileSync} from 'node:fs';
import {parseNativeStations} from './aprs-activity.mjs';
const context=vm.createContext({window:{}});
vm.runInContext(readFileSync(new URL('./public/aprs-symbols.js',import.meta.url),'utf8'),context);
const decode=context.window.BPQAprsPacket.decode;
const mic='`\x7f^U!n^>/';
test('Mic-E station descriptions decode movement and base91 altitude instead of showing binary position bytes',()=>{
const info=decode(mic+'"5J}');
assert.equal(info.format,'Mic-E');assert.equal(info.speedKmh,107);assert.equal(info.course,266);assert.equal(info.altitudeM,142);assert.equal(info.comment,'');
assert.equal(decode(mic+'"5J}Hello from the car').comment,'Hello from the car');
assert.equal(decode('`short').speedKmh,null);assert.equal(decode('`short').comment,'');
});
test('known Mic-E device identifiers are separated from comments; unknown suffixes and real comments are preserved',()=>{
const info=decode(mic+'`"5J}Test_3');assert.equal(info.device,'Yaesu FT5D');assert.equal(info.altitudeM,142);assert.equal(info.comment,'Test');
assert.equal(decode(mic+'>Hello=').device,'Kenwood TH-D72');
assert.equal(decode(mic+'`Hello?Z').comment,'Hello?Z');
assert.equal(decode(mic+'<hello & world>').comment,'<hello & world>');
});
test('plain position descriptions omit position fields without damaging the transmitted text',()=>{
assert.equal(decode('!4534.18N/00907.89E]Local BBS').comment,'Local BBS');
assert.equal(decode('@191200z4534.18N/00907.89E]Local BBS').comment,'Local BBS');
assert.equal(decode('>191200zOn air').comment,'On air');
assert.equal(decode('Comment\x7f with controls').comment,'Comment with controls');
});
test('native HTML decoding preserves Mic-E byte positions, literal angle brackets and repeated spaces',()=>{
const body='`\x7f&lt;U ^&gt;/"5J}';
const row='A,45.5,9.1,N0TEST,TEST,WIDE1-1<br>'+body+'<br>Last Heard: 12:00:00 on Port 3<br>,010D@,1\r\n|';
const station=parseNativeStations(row)[0];
assert.equal(station.lastBody,'`\x7f<U ^>/"5J}');assert.equal(station.lastBody[7],'>');assert.equal(station.lastBody[8],'/');
assert.equal(decode(station.lastBody).altitudeM,142);
});