Render local APRS symbol sprites with table and overlay details while preserving markers and open popups during refresh. Open the map around the local station with a 30 km radius and fit the densest station group without distant outliers. Add localization, attribution and regression coverage.
31 lines
2.0 KiB
JavaScript
31 lines
2.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {aprsSymbol,nativeSymbol} from './aprs-symbols.mjs';
|
|
import {parseNativeStations,positionOf} from './aprs-activity.mjs';
|
|
import vm from 'node:vm';
|
|
import {readFileSync} from 'node:fs';
|
|
|
|
test('APRS codes distinguish the primary, alternate and overlay tables without guessing a station type',()=>{
|
|
assert.deepEqual(nativeSymbol('010D@'),aprsSymbol('/','>'));
|
|
assert.deepEqual(nativeSymbol('0602W'),aprsSymbol('W','#'));
|
|
assert.deepEqual(nativeSymbol('0602@'),aprsSymbol('\\','#'));
|
|
for(const key of ['FFFF@','000FZ','0B0E@','bad'])assert.equal(nativeSymbol(key),null);
|
|
assert.equal(aprsSymbol('?','>'),null);assert.equal(aprsSymbol('/','<script>'),null);
|
|
const station=parseNativeStations('A,45,9,N0TEST,APRS<br>Mic-E<br>,0602W,10\r\n|')[0];
|
|
assert.equal(station.position.symbol,'#');assert.equal(station.position.symset,'W');assert.equal(station.position.overlay,'W');
|
|
assert.deepEqual(aprsSymbol(positionOf('!4534.18NW00907.89E#').symset,'#'),aprsSymbol('W','#'));
|
|
});
|
|
test('local sprites use the correct ASCII slot and escaped, validated overlay characters',()=>{
|
|
const context=vm.createContext({window:{}});vm.runInContext(readFileSync(new URL('./public/aprs-symbols.js',import.meta.url),'utf8'),context);
|
|
const symbols=context.window.BPQAprsSymbols;
|
|
assert.equal(symbols.decode({symset:'/',symbol:'>'}).name,'Car');
|
|
assert.match(symbols.html({symset:'/',symbol:'>'}),/primary.*col-13.*row-1/);
|
|
assert.match(symbols.html({symset:'W',symbol:'#'}),/alternate.*col-2.*row-0.*overlay">W/);
|
|
assert.match(symbols.html({symset:'<',symbol:'>'}),/unknown/);
|
|
assert.equal(symbols.decode({}),null);
|
|
assert.doesNotMatch(symbols.html({symset:'/',symbol:'>'}),/style=|class="primary/);
|
|
const css=readFileSync(new URL('./public/aprs-activity.css',import.meta.url),'utf8');
|
|
assert.match(css,/\.aprs-symbol-col-13\{background-position-x:-312px\}/);
|
|
assert.match(css,/\.aprs-symbol-row-1\{background-position-y:-24px\}/);
|
|
});
|