import { test } from "node:test"; import assert from "node:assert/strict"; import { audioBytesPerHour, spaceComparator } from "./spaceOrder"; test("space order: corpus-disk channels first, then the most bytes freed per audio-hour; unknown last; ties stable", () => { const external = new Set(["x1", "x2"]); const rate: Record = { a: 10, b: 50, c: null, d: 50, x1: 900, x2: null }; const cmp = spaceComparator({ external: (id) => external.has(id), bytesPerHour: (id) => rate[id] ?? null }); assert.deepEqual(["c", "x1", "a", "b", "x2", "d"].sort(cmp), ["b", "d", "a", "c", "x1", "x2"]); }); test("audioBytesPerHour: bytes over hours; nothing to say without both", () => { assert.equal(audioBytesPerHour(3_600_000, 1800), 7_200_000); assert.equal(audioBytesPerHour(0, 1800), null); assert.equal(audioBytesPerHour(100, null), null); assert.equal(audioBytesPerHour(100, 0), null); });