refactor: convert APRS plugin to TypeScript
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
import vm from "node:vm";
|
||||
|
||||
test("APRS entry normalizes positioned packets without remote symbol assets", async () => {
|
||||
const forwarded = [];
|
||||
const window = {
|
||||
trxUi: { confirm: async () => true },
|
||||
aprsMapAddStation: (...args) => { forwarded.push(args); },
|
||||
};
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: { getElementById: () => null, querySelectorAll: () => [] },
|
||||
navigator: {},
|
||||
Date,
|
||||
Number,
|
||||
String,
|
||||
Array,
|
||||
Set,
|
||||
Reflect,
|
||||
console,
|
||||
});
|
||||
const source = await readFile(new URL("../../assets/web/generated/aprs.js", import.meta.url), "utf8");
|
||||
assert.equal(source.includes("raw.githubusercontent.com"), false);
|
||||
new vm.Script(source).runInContext(context);
|
||||
|
||||
window.onServerAprs({ src_call: "SP0ABC", dest_call: "APRS", crc_ok: true, lat: 54.5, lon: 18.5, symbol_table: "/", symbol_code: ">" });
|
||||
assert.equal(forwarded.length, 1);
|
||||
assert.equal(forwarded[0][0], "SP0ABC");
|
||||
assert.equal(forwarded[0][1], 54.5);
|
||||
assert.equal(forwarded[0][6].rig_id, null);
|
||||
});
|
||||
Reference in New Issue
Block a user