Skip to content

fix: resolve all failing tests in utility library#218

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2384-1781752293
Open

fix: resolve all failing tests in utility library#218
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2384-1781752293

Conversation

@stooit

@stooit stooit commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across 5 utility modules. The full suite now passes (60 pass / 0 fail). No test files were modified and no dependencies were added.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • src/string-utils.tswordCount correctly handles multiple consecutive spaces; truncate implemented (unchanged within limit, word-boundary cut, ellipsis counts toward maxLength, handles strings shorter than the ellipsis).
  • src/task-manager.ts — added missing remove, update, and sortBy (priority high>medium>low, createdAt oldest-first) methods.
  • src/date-utils.ts — fixed off-by-one in formatRelative (now uses Math.round, so 36h → "2 days ago").
  • src/validator.tsisEmail accepts long TLDs; isUrl accepts URLs with a port.

Testing

bun test60 pass, 0 fail, 70 expect() calls.

Review notes (non-blocking, outside test scope)

  • truncate: a maxLength <= ellipsis length returns a bare slice without ellipsis — defensible for degenerate input, spec-unspecified.
  • formatRelative: hours branch can report "24 hours ago" at the 24h boundary — pre-existing, not introduced here.

Assumptions

  • Tests are the authoritative spec; source was changed to satisfy them.
  • Existing function signatures and the public API shape were preserved.

- calculator: throw on division by zero instead of returning Infinity
- string-utils: fix wordCount whitespace handling; implement truncate
- task-manager: add remove, update, and sortBy methods
- date-utils: fix off-by-one in formatRelative (Math.round)
- validator: accept long TLDs in isEmail and ports in isUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant