forked from retoor/devplacepy
21 lines
1.1 KiB
JavaScript
21 lines
1.1 KiB
JavaScript
import test from "node:test";
|
|||
|
|
import assert from "node:assert/strict";
|
||
|
|
import { describeState, displayLabel } from "../ui/popup.js";
|
||
|
|
|
||
|
|
test("a suspended state shows the end time in DD/MM/YYYY and says it retries", () => {
|
||
|
|
const text = describeState({ state: "suspended", suspendedUntil: "2026-03-05T10:07:00Z", detail: "x" });
|
||
|
|
assert.match(text, /^Suspended until \d{2}\/\d{2}\/2026 \d{2}:\d{2}, retrying automatically$/);
|
||
|
|
assert.equal(describeState({ state: "suspended", suspendedUntil: "" }), "Suspended, retrying automatically");
|
||
|
|
});
|
||
|
|
|
||
|
|
test("other states show detail then last error", () => {
|
||
|
|
assert.equal(describeState({ state: "online", detail: "ok", lastError: "e" }), "ok");
|
||
|
|
assert.equal(describeState({ state: "backoff", detail: "", lastError: "e" }), "e");
|
||
|
|
});
|
||
|
|
|
||
|
|
test("the server label is the authority and the local label is the fallback", () => {
|
||
|
|
assert.equal(displayLabel({ deviceLabel: "Server name" }, { label: "typed" }), "Server name");
|
||
|
|
assert.equal(displayLabel({ deviceLabel: "" }, { label: "typed" }), "typed");
|
||
|
|
assert.equal(displayLabel({}, { label: "typed" }), "typed");
|
||
|
|
});
|