Skip to content

fix: implement missing utilities and fix edge-case bugs - #257

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2469-1784738194
Open

fix: implement missing utilities and fix edge-case bugs#257
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2469-1784738194

Conversation

@stooit

@stooit stooit commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes all 16 previously-failing tests pass (now 60 pass / 0 fail) by implementing missing functionality and fixing edge-case bugs across the utility library. No test files were modified and no dependencies were added.

Changes

  • calculatordivide now throws Error("Division by zero") when the divisor is 0.
  • string-utils — implemented truncate (truncates at a word boundary with "..." counting toward maxLength); fixed wordCount to split on /\s+/ so consecutive spaces don't inflate the count.
  • task-manager — implemented remove (returns false for unknown id), update (merges changes, false for unknown id), and sortBy (non-mutating sort by createdAt, priority, or status).
  • date-utils — fixed formatRelative off-by-one: uses Math.round on the hours→days conversion (e.g. 36h → "2 days ago").
  • validatorisEmail now accepts subdomains and long TLDs; isUrl no longer rejects URLs without an explicit port.

Also removed two stale BUG: comments in date-utils.ts and validator.ts that described the now-fixed bugs.

Testing

bun test → 60 pass, 0 fail, 70 expect() calls.

Assumptions

  • Kept fixes minimal and scoped strictly to what the tests assert.
  • sortBy returns a new sorted array rather than mutating the internal task map.

Reviewed by the review subagent (verdict: approve).

- calculator: guard divide against division by zero
- string-utils: implement truncate (word-boundary + ellipsis), fix wordCount whitespace split
- task-manager: implement remove, update, and sortBy methods
- date-utils: fix formatRelative off-by-one (round instead of floor)
- validator: fix isEmail (subdomains/long TLDs) and isUrl edge cases

All 60 tests 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