Skip to content

fix: make all tests pass — implement missing utilities and fix edge-case bugs - #287

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2211-1786724490
Open

fix: make all tests pass — implement missing utilities and fix edge-case bugs#287
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2211-1786724490

Conversation

@stooit

@stooit stooit commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library (60/60 pass, previously 44/60). Only source files under src/ were changed — no test files edited, no dependencies added, per the task constraints.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of silently returning Infinity.
  • src/string-utils.tswordCount splits on /\s+/ (handles consecutive spaces, tabs, newlines); implemented truncate with word-boundary cutting and an ellipsis budget so output never exceeds maxLength.
  • src/task-manager.ts — implemented the missing remove, update, and sortBy methods. sortBy uses typed rank maps (high > medium > low) and ascending createdAt (oldest first).
  • src/date-utils.ts — fixed off-by-one in formatRelative day bucketing (Math.round instead of Math.floor); Math.abs moved before rounding so past/future dates stay symmetric.
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts port-bearing URLs (e.g. http://localhost:3000) while keeping the protocol allowlist (rejects ftp:, javascript:, data:).

Verification

  • bun test60 pass / 0 fail
  • tsc --noEmit (strict) → clean

Notes & assumptions

  • Fixes were kept minimal and scoped to what the tests require, as instructed. A review pass flagged non-blocking hardening opportunities (negative/NaN maxLength guards in truncate, a runtime default in sortBy, ability to clear optional fields in update) — all outside the test requirements and left as-is to avoid scope creep.
  • Security note for downstream callers: isUrl is now port-agnostic (http://localhost:3000, http://[::1]:8080 pass), so it must not be relied on as an SSRF/open-redirect allowlist. isEmail remains a structural check, not RFC 5322 validation or proof of deliverability.

…ests

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: fix wordCount whitespace splitting; implement truncate with word-boundary + ellipsis budget
- task-manager: implement remove, update, and sortBy methods
- date-utils: fix off-by-one in formatRelative day bucketing (round vs floor)
- validator: accept long TLDs in isEmail; accept port-bearing 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