feat: add driver runtime manager
This commit is contained in:
1 parent
a8c08cd7e9
commit
a799958328
23 files changed
+1044
-12
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
formatRuntimeBytes,
|
||||
formatRuntimeCpu,
|
||||
formatRuntimeUptime,
|
||||
runtimeHealthClass,
|
||||
runtimeStatusDotClass,
|
||||
runtimeStatusClass,
|
||||
} from "../../apps/desktop/src/lib/driverRuntimePresentation.ts";
|
||||
|
||||
test("formats runtime byte counts compactly", () => {
|
||||
assert.equal(formatRuntimeBytes(null), "-");
|
||||
assert.equal(formatRuntimeBytes(12_288), "12 KB");
|
||||
assert.equal(formatRuntimeBytes(2_621_440), "2.5 MB");
|
||||
});
|
||||
|
||||
test("formats runtime CPU and uptime", () => {
|
||||
assert.equal(formatRuntimeCpu(undefined), "-");
|
||||
assert.equal(formatRuntimeCpu(1.234), "1.2%");
|
||||
assert.equal(formatRuntimeUptime(45), "45s");
|
||||
assert.equal(formatRuntimeUptime(125), "2m");
|
||||
assert.equal(formatRuntimeUptime(7_500), "2h 5m");
|
||||
});
|
||||
|
||||
test("maps runtime state to visual classes", () => {
|
||||
assert.match(runtimeStatusClass("running"), /emerald/);
|
||||
assert.match(runtimeStatusDotClass("running"), /emerald/);
|
||||
assert.match(runtimeStatusClass("stopped"), /muted/);
|
||||
assert.match(runtimeHealthClass("warning"), /amber/);
|
||||
});
|
||||
Reference in new issue
Block a user