refactor: convert satellite scheduler to TypeScript

This commit is contained in:
sjg
2026-08-01 12:54:03 +02:00
parent 4fb65971e4
commit fc2f55bab9
7 changed files with 408 additions and 332 deletions
@@ -0,0 +1,29 @@
// 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 scheduler exposes a typed config adapter with safe defaults", async () => {
const window = {};
const context = vm.createContext({
window,
document: { getElementById: () => null, createDocumentFragment: () => ({ appendChild() {} }) },
Date,
Number,
String,
Array,
console,
});
const source = await readFile(new URL("../../assets/web/generated/sat-scheduler.js", import.meta.url), "utf8");
new vm.Script(source).runInContext(context);
assert.equal(typeof window.satScheduler.wireEvents, "function");
assert.deepEqual(
JSON.parse(JSON.stringify(window.satScheduler.collectSatelliteConfig())),
{ enabled: false, pretune_secs: 60, entries: [] },
);
});