// An agent's open todos: their order and the count in words. Run by `npm test`. import assert from "node:assert/strict"; import { test } from "node:test"; import { sortTodos, todosLabel } from "../src/agent/terminal/agent-todos.ts"; const todo = (id, updated_unix) => ({ id, subsystem: "forge", summary: `todo ${id}`, updated_unix, }); test("the newest todo comes first and a tie goes to the higher id", () => { const ids = sortTodos([ todo(1, 100), todo(2, 300), todo(3, 300), todo(4, 200), ]).map((t) => t.id); assert.deepEqual(ids, [3, 2, 4, 1]); }); test("sorting leaves the list it was given alone", () => { const list = [todo(1, 100), todo(2, 200)]; sortTodos(list); assert.deepEqual( list.map((t) => t.id), [1, 2], ); }); test("the count reads in words", () => { assert.equal(todosLabel([]), "no open todos"); assert.equal(todosLabel([todo(1, 1)]), "1 open todo"); assert.equal(todosLabel([todo(1, 1), todo(2, 2)]), "2 open todos"); });