Skip to content

fix: repair all failing tests across utility modules - #295

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2097-1787069446
Open

fix: repair all failing tests across utility modules#295
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2097-1787069446

Conversation

@stooit

@stooit stooit commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the 5 utility modules. Test suite goes from 44 pass / 16 fail to 60 pass / 0 fail. tsc --noEmit is clean. No test files were modified and no dependencies were added — only the 5 src/ files changed.

Changes by module

  • calculator.tsdivide now throws on a zero divisor (incl. -0) instead of returning Infinity.
  • string-utils.tswordCount splits on whitespace runs (/\s+/ on the trimmed string) so consecutive spaces/tabs/newlines no longer inflate the count. truncate implemented: returns input unchanged within limit, otherwise cuts at a word boundary within the ellipsis budget, with a hard-cut fallback for over-long single words. Guards non-finite / <= 0 maxLength to "".
  • task-manager.tsremove returns true/false on hit/miss; update returns false for unknown ids and applies only keys present in changes (partial-update semantics); sortBy returns a sorted copy with rank maps for priority/status, createdAt ascending, and a numeric-id tiebreak for deterministic ordering.
  • date-utils.tsformatRelative rounds the day magnitude, fixing the 36h boundary (now "2 days ago") and keeping past/future phrasing symmetric.
  • validator.tsisEmail accepts multi-level subdomains and 2+ char TLDs (e.g. .museum); isUrl no longer rejects valid URLs that carry a port (e.g. http://localhost:3000).

Verification

  • bun test → 60 pass, 0 fail, 70 expect() calls
  • tsc --noEmit → clean
  • Reviewed by the review subagent; two edge-case robustness findings were folded in before commit.

Assumptions

  • Kept isUrl's existing protocol allowlist (rejects ftp:/javascript:/data:).
  • sortBy returns a sorted copy rather than mutating internal state.
  • truncate treats non-finite / non-positive maxLength as "".

- calculator: divide now throws on zero divisor instead of returning Infinity
- string-utils: implement truncate (word-boundary, ellipsis budget, edge guards); wordCount splits on whitespace runs
- task-manager: implement remove/update partial semantics and sortBy with stable tiebreak
- date-utils: formatRelative rounds day magnitude symmetrically (fixes 36h boundary)
- validator: isEmail accepts multi-level subdomains and 2+ char TLDs; isUrl no longer rejects URLs with a port
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