Skip to content

fix: implement missing utilities and fix edge-case bugs to pass all tests - #286

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2098-1786638155
Open

fix: implement missing utilities and fix edge-case bugs to pass all tests#286
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2098-1786638155

Conversation

@stooit

@stooit stooit commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes all 60 tests pass (was 44 pass / 16 fail) across the TypeScript utility library. Only src/ files changed — no test files modified, no dependencies added.

Changes

  • calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • date-utils.ts — Fixed off-by-one in formatRelative: days computed as round(hours/24), so 36h correctly reads "2 days ago" while 24h stays "1 day ago".
  • string-utils.ts — Implemented truncate (word-boundary cut, ellipsis counted within maxLength, result always ≤ maxLength); fixed wordCount to collapse consecutive whitespace (/\s+/).
  • task-manager.ts — Implemented remove (boolean), update (partial, only applies defined keys, false for unknown id), and sortBy (priority high→medium→low, status, createdAt oldest-first).
  • validator.tsisEmail accepts subdomains and long TLDs (e.g. user@example.museum) while still rejecting empty labels/spaces; isUrl accepts URLs with ports (e.g. http://localhost:3000) with the scheme allowlist retained.

Verification

  • bun test60 pass, 0 fail
  • tsc --noEmit clean
  • Independent review pass confirmed all five are genuine fixes (not test-shaped hacks) and each generalises beyond its assertions. Email regex checked for ReDoS — confirmed linear, not exponential.

Assumptions / notes

  • Followed the task constraint "fix only what the tests require." A review flagged non-blocking follow-ups outside test scope: truncate with leading-whitespace-only input, isUrl validating syntax/scheme only (not SSRF destination safety), and a sortBy insertion-tiebreak that assumes numeric ids. None are regressions; left as-is to keep the change minimal.

…ests

- calculator: divide now throws on division by zero instead of returning Infinity
- date-utils: fix off-by-one in formatRelative (round hours/24, so 36h reads '2 days ago')
- string-utils: implement truncate (word-boundary, ellipsis within maxLength) and fix wordCount for consecutive whitespace
- task-manager: implement remove, update (partial), and sortBy (priority/status/createdAt)
- validator: isEmail accepts subdomains and long TLDs; isUrl accepts URLs with ports

All 60 tests pass; no test files modified.
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