Skip to content

fix: resolve 16 failing tests across utility modules - #304

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2159-1787761932
Open

fix: resolve 16 failing tests across utility modules#304
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2159-1787761932

Conversation

@stooit

@stooit stooit commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the utility library. Test suite now passes 60/60 (was 44 pass / 16 fail). Only source files were changed — no test files modified, no dependencies added.

Changes by file

  • src/calculator.tsdivide now throws RangeError on division by zero instead of returning Infinity (fail-fast on invalid input).
  • src/string-utils.ts — implemented truncate (reserves 3 chars for "...", cuts to word boundary); fixed wordCount to split on /\s+/ so consecutive/other whitespace no longer inflates counts.
  • src/task-manager.ts — implemented remove (Map.delete), update (partial update guarded by explicit key presence, returns false for unknown id), and sortBy (sorts a copy; data-driven priority/status rank maps; createdAt oldest-first).
  • src/date-utils.tsdiffDays uses Math.round(Math.abs(diffHours) / 24) instead of Math.floor, fixing the off-by-one (36h → "2 days ago") symmetrically for past and future dates.
  • src/validator.tsisEmail TLD quantifier {2,4}{2,} (accepts .museum etc.); isUrl drops the spurious empty-port check so http://localhost:3000 validates, while retaining the http/https allow-list.

Verification

  • bun test → 60 pass / 0 fail
  • tsc --noEmit clean (strict mode)
  • Independent review pass confirmed tests were unmodified (60 tests present before and after) and that each fix is a genuine general implementation, not test-gaming.

Assumptions & notes

  • Fixed only what the tests require, per task constraints. A review pass flagged optional, non-blocking polish for truncate — left unchanged as no test requires it.
  • divide throwing is a behavioural change for any caller relying on native Infinity semantics; the test and the original // BUG: comment both require the throw.
  • isEmail/isUrl remain format-shape checks, not RFC-grade or SSRF-safe validation — appropriate for their current use.

… edge cases

Implements TaskManager remove/update/sortBy and string truncate; corrects
day rounding in formatRelative and relaxes email TLD / URL port validation.

Fixes 16 failing tests (60/60 now pass).
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