#11421: Tests: add unit tests for infra/format-duration
stale
size: S
Cluster:
Backoff and Duration Tests
## Summary
- Add `src/infra/format-duration.test.ts` with 14 tests covering both `formatDurationSeconds()` and `formatDurationMs()`
- Covers: non-finite values (NaN, Infinity), negative inputs, zero, trailing zero trimming, decimal precision options, unit labels (`s` vs `seconds`), and the ms-to-seconds threshold at 1000ms
## Test plan
- [x] All 14 tests pass locally via `vitest run src/infra/format-duration.test.ts`
- [x] AI-assisted (Claude Code), tested, and verified against source implementation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a new Vitest unit test file (`src/infra/format-duration.test.ts`) covering `formatDurationSeconds()` and `formatDurationMs()` across typical values and edge cases (non-finite numbers, negatives, zero, trailing-zero trimming, decimals option, unit label options, and the 1000ms threshold behavior). The tests align with the current implementation in `src/infra/format-duration.ts` (e.g., `formatDurationMs` returning raw `ms` strings for values `< 1000`, and delegating to `formatDurationSeconds` with a default of 2 decimals).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Changes are limited to adding a new unit test file, and the assertions match the current `format-duration` implementation (including edge-case handling and default options). No production code paths are modified.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#4095: Test/add format duration tests
by TechWizard9999 · 2026-01-29
89.5%
#4137: [AI-assisted] test(cli): add missing test cases for parseDurationMs
by sind00 · 2026-01-29
87.2%
#9333: Tests: add test coverage for security/audit-fs.ts
by M00N7682 · 2026-02-05
81.3%
#12684: Test: add missing unit tests for src/utils modules
by shaynhornik · 2026-02-09
79.4%
#15569: test: comprehensive test coverage expansion (57 new test files)
by tangcruz · 2026-02-13
78.9%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
77.3%
#8964: test(msteams): add comprehensive tests for graph-upload module
by RajdeepKushwaha5 · 2026-02-04
76.1%
#4086: Test/add backoff tests
by TechWizard9999 · 2026-01-29
75.4%
#7507: test(ci): make tests cross-platform (Windows) + add basic sanitizat...
by ThinkIbrokeIt · 2026-02-02
74.3%
#12087: Add comprehensive tests for markdown code-spans module
by YassineOUAHMANE · 2026-02-08
73.3%