refactor: convert WEFAX plugin to TypeScript
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// 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("WEFAX entry exposes typed lifecycle handlers and renders decoder state", async () => {
|
||||
const status = { textContent: "", style: { color: "" } };
|
||||
const window = {};
|
||||
const context = vm.createContext({
|
||||
window,
|
||||
document: { getElementById: (id) => id === "wefax-status" ? status : null },
|
||||
Date,
|
||||
Number,
|
||||
String,
|
||||
Uint8Array,
|
||||
console,
|
||||
});
|
||||
const source = await readFile(new URL("../../assets/web/generated/wefax.js", import.meta.url), "utf8");
|
||||
new vm.Script(source).runInContext(context);
|
||||
|
||||
assert.equal(typeof window.onServerWefaxProgress, "function");
|
||||
assert.equal(typeof window.restoreWefaxHistory, "function");
|
||||
window.onServerWefaxProgress({ state: "Scanning 12 MHz" });
|
||||
assert.equal(status.textContent, "Scanning 12 MHz");
|
||||
assert.equal(status.style.color, "var(--text-accent)");
|
||||
});
|
||||
Reference in New Issue
Block a user