refactor: share typed APRS plugin contracts

This commit is contained in:
sjg
2026-08-01 12:48:33 +02:00
parent 074c67c7b9
commit 021d31d780
9 changed files with 735 additions and 807 deletions
@@ -0,0 +1,31 @@
// 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("HF APRS entry uses shared typed normalization and local symbols", async () => {
const window = { trxUi: { confirm: async () => true } };
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/hf-aprs.js", import.meta.url), "utf8");
assert.equal(source.includes("raw.githubusercontent.com"), false);
new vm.Script(source).runInContext(context);
window.onServerHfAprs({ src_call: "SP0ABC", dest_call: "APRS", crc_ok: true, symbol_table: "/", symbol_code: ">" });
assert.equal(typeof window.restoreHfAprsHistory, "function");
assert.equal(typeof window.pruneHfAprsHistoryView, "function");
});