refactor: convert satellite view 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("satellite entry registers lifecycle callbacks and forwards georeferenced images", async () => {
|
||||
const overlays = [];
|
||||
const window = {
|
||||
trxUi: { confirm: async () => true },
|
||||
addSatMapOverlay: (image) => { overlays.push(image); },
|
||||
};
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: { getElementById: () => null, createDocumentFragment: () => ({ appendChild() {} }) },
|
||||
fetch: async () => ({ ok: true, json: async () => ({ satellite_count: 0, passes: [] }) }),
|
||||
setInterval: () => 1,
|
||||
clearInterval() {},
|
||||
Date,
|
||||
Number,
|
||||
String,
|
||||
Array,
|
||||
Error,
|
||||
console,
|
||||
});
|
||||
const source = await readFile(new URL("../../assets/web/generated/sat.js", import.meta.url), "utf8");
|
||||
new vm.Script(source).runInContext(context);
|
||||
|
||||
window.onServerLrptImage({ path: "/images/lrpt.png", geo_bounds: [50, 10, 55, 20], mcu_count: 100 });
|
||||
assert.equal(overlays.length, 1);
|
||||
assert.deepEqual(overlays[0].geo_bounds, [50, 10, 55, 20]);
|
||||
assert.equal(typeof window.updateSatLiveState, "function");
|
||||
assert.equal(typeof window.resetSatHistoryView, "function");
|
||||
});
|
||||
Reference in New Issue
Block a user