Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/frontend/packages/swarm-ui/test/status-message.test.mjs
iris 818d41eef3 swarm ui: the status age helpers live in status-fields.ts
StatusMessage.tsx and statusMessage.ts differ only by case, which the esbuild step in the nix build can't read on a case-insensitive builder.
2026-11-11 01:25:15 +01:00

32 lines
1 KiB
JavaScript

// The agent status message and its age. Run by `npm test`, which Node runs
// with its built-in test runner and type stripping, so the `.ts` module is
// imported as it is.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
statusSetAtMs,
statusText,
} from "../src/agent/detail/status-fields.ts";
const snap = (status_text, status_set_at) => ({
status_text,
status_set_at,
running: true,
});
test("the set time is read from seconds to ms, or is nothing", () => {
assert.equal(
statusSetAtMs(snap("working", 1_731_000_000)),
1_731_000_000_000,
);
assert.equal(statusSetAtMs(snap("working", null)), null);
assert.equal(statusSetAtMs(snap("working", 0)), null);
assert.equal(statusSetAtMs(null), null);
});
test("an agent with no message shows a dash", () => {
assert.equal(statusText(snap("fixing a bug", 1)), "fixing a bug");
assert.equal(statusText(snap(null, 1)), "—");
assert.equal(statusText(snap("", 1)), "—");
assert.equal(statusText(null), "—");
});