Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2222-1787019955
Open

fix: resolve 16 failing tests across utility modules#293
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2222-1787019955

Conversation

@stooit

@stooit stooit commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests in the utility library. Test suite now reports 60 pass / 0 fail (was 44 pass / 16 fail). Only the five src/ files were modified — no test files touched, no dependencies added.

Changes

  • src/calculator.tsdivide now throws on a zero divisor instead of returning Infinity (fail-closed on invalid input).
  • src/string-utils.ts — implemented truncate (word-boundary aware, never exceeds maxLength); fixed wordCount to split on /\s+/ after trimming so runs of whitespace and whitespace-only input count correctly.
  • src/task-manager.ts — implemented remove (returns true/false), update (partial update, returns false for unknown id, omitted keys never clobber existing values), and sortBy (priority/status rank maps, chronological createdAt; sorts a copy, non-mutating).
  • src/date-utils.ts — fixed off-by-one in formatRelative: day bucket now uses Math.round(abs(diffHours)/24) instead of a pre-sign floor, so 36 hours correctly reads "2 days ago".
  • src/validator.tsisEmail accepts long TLDs (example.museum) via {2,}; isUrl accepts host:port URLs (http://localhost:3000) by dropping the erroneous empty-port rejection, while still restricting the scheme allowlist to http/https.

Verification

  • bun test → 60 pass / 0 fail (70 expect() calls)
  • tsc --noEmit clean
  • No test files modified; no dependencies added

Assumptions / notes

  • isEmail is a pragmatic format-validation regex, not RFC 5322-complete — it should not be treated as proof an address is deliverable. If these validators gate anything security-relevant, delivery confirmation is the real control.

- calculator: divide now throws on zero divisor instead of returning Infinity
- string-utils: implement truncate; fix wordCount to collapse whitespace
- task-manager: implement remove/update/sortBy with correct semantics
- date-utils: fix off-by-one in formatRelative day bucketing (round vs floor)
- validator: accept long TLDs in isEmail; accept host:port URLs 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