refactor: convert VDES plugin to TypeScript
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// 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("VDES entry normalizes and forwards positioned server messages", async () => {
|
||||
const forwarded = [];
|
||||
const window = {
|
||||
trxUi: { confirm: async () => true },
|
||||
vdesMapAddPoint: (message) => { forwarded.push(message); },
|
||||
};
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: { getElementById: () => null },
|
||||
Date,
|
||||
Number,
|
||||
String,
|
||||
Array,
|
||||
console,
|
||||
});
|
||||
const source = await readFile(new URL("../../assets/web/generated/vdes.js", import.meta.url), "utf8");
|
||||
new vm.Script(source).runInContext(context);
|
||||
|
||||
window.onServerVdes({ callsign: "SP0ABC", lat: 54.5, lon: 18.5, bit_len: 120, ts_ms: Date.now() });
|
||||
assert.equal(forwarded.length, 1);
|
||||
assert.equal(forwarded[0].callsign, "SP0ABC");
|
||||
assert.equal(forwarded[0].rig_id, null);
|
||||
assert.equal(typeof forwarded[0]._tsMs, "number");
|
||||
});
|
||||
Reference in New Issue
Block a user