import test from "node:test";
import assert from "node:assert/strict";
import { elapsedSeconds, formatElapsed } from "./elapsed-time.js";

test("elapsed time freezes at completion", () => {
  assert.equal(elapsedSeconds({ startedAt: 1000, completedAt: 4500 }, 9000), 3);
});

test("elapsed time advances while work is active", () => {
  assert.equal(elapsedSeconds({ startedAt: 1000 }, 6200), 5);
});

test("elapsed time formats minutes and seconds", () => {
  assert.equal(formatElapsed(65), "1m 5s");
  assert.equal(formatElapsed(8), "8s");
});
