Files
openclaw/test/scripts/format-duration.test.ts
RoboClawandsteipete 1a5325f035 refactor: remove narrowly used helper dependencies (#158573)
* refactor: remove narrowly used helper dependencies

Replace markdown-it-task-lists and grammY runner sequencing with their local owners. Remove direct ms/pretty-ms usage and share the existing duration factors and formatting. Preserve rendering and parsing contracts, and keep overlapping Telegram lanes ordered when a predecessor fails.

Remove obsolete mocks, declarations, dependency metadata, and build references; regenerate the lockfile and Control UI boot manifest. Deduplicate an inherited over-limit replay test without changing coverage.

Closes #158499

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: f4ef665a-7e2b-47ce-a454-adc19e798bee

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: abec5219-5bd0-4480-8604-a57c1063f638

* fix(ci): preserve base-only dependencies in UI comparison

Materialize removed dependency declarations from the archived base lockfile before overlaying the candidate toolchain. Keep both builds on the same Vite and compressor without restoring removed application dependencies.

Extend the real build regression with a dependency absent from the candidate and verify the original comparator fails to resolve it.

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: 2db2eea4-87fe-4071-ab37-28da02f1bd24

* refactor: remove narrowly used helper dependencies

Worked on by:
- @steipete

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
OpenClaw-Publication: 8c381a6d-38f2-417f-85ee-9353cb5694dc

---------

Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
2026-09-26 22:38:09 -07:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { formatDurationElapsed } from "../../scripts/lib/format-duration.mts";
describe("formatDurationElapsed", () => {
it.each<[number, 1 | 2, string]>([
[0, 1, "0ms"],
[999, 1, "999ms"],
[1_000, 1, "1s"],
[1_100, 2, "1.10s"],
[1_230, 2, "1.23s"],
[3_100, 1, "3.1s"],
[10_000, 2, "10s"],
[12_300, 1, "12.3s"],
[59_900, 1, "59.9s"],
[60_000, 1, "1m"],
[60_100, 1, "1m 0.1s"],
[3_661_100, 1, "1h 1m 1.1s"],
[86_400_100, 1, "1d 0.1s"],
[31_626_061_100, 1, "1y 1d 1h 1m 1.1s"],
])("formats %dms with %d second decimals", (input, secondsDecimalDigits, expected) => {
expect(formatDurationElapsed(input, { secondsDecimalDigits })).toBe(expected);
});
it("folds years into days for smoke timings and skips empty units", () => {
expect(formatDurationElapsed(31_622_401_000, { showYears: false, unitCount: 2 })).toBe(
"366d 1s",
);
});
it.each([
[0, "0ms"],
[999, "999ms"],
[1_100, "1.1s"],
[59_900, "59.9s"],
[60_100, "1m"],
[3_660_000, "1h"],
[31_622_400_000, "1y"],
])("keeps only the first nonzero timing unit for %dms", (input, expected) => {
expect(formatDurationElapsed(input, { unitCount: 1 })).toBe(expected);
});
});