Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2308-1784306012
Open

fix: implement missing utilities and fix edge-case bugs#252
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2308-1784306012

Conversation

@stooit

@stooit stooit commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. All 60 tests now pass (0 fail), and no previously-passing tests were broken. Only src/ files were changed — test files are untouched and no dependencies were added.

Changes

File Fix
src/calculator.ts divide now throws Error("Division by zero") when the divisor is 0 (previously returned Infinity).
src/string-utils.ts Implemented truncate — truncates at a word boundary with "..." counting toward maxLength, returns the string unchanged when within the limit. Fixed wordCount to split on /\s+/ so consecutive spaces don't inflate the count.
src/task-manager.ts Implemented the missing/incomplete remove(), update(), and sortBy() methods (remove/update return false for unknown ids; sortBy supports priority high→medium→low and createdAt oldest-first).
src/date-utils.ts Fixed off-by-one in formatRelative — uses Math.round instead of Math.floor, so 36h ago correctly reads "2 days ago".
src/validator.ts Fixed isEmail to accept long TLDs and isUrl to accept URLs with a port.

Also removed two now-inaccurate // BUG: comments in string-utils.ts and date-utils.ts that described the old broken behaviour.

Verification

  • bun test60 pass / 0 fail (70 expect() calls).
  • Independent review confirmed the implementations are correct and don't break other functions' contracts.

Assumptions

  • Followed the behaviour specified by the existing tests and inline TODOs; where a TODO described the intended contract (e.g. ellipsis counting toward maxLength), that contract was implemented as written.

- calculator: divide now throws on division by zero
- string-utils: implement truncate (word-boundary + ellipsis), fix wordCount whitespace splitting
- task-manager: implement remove(), update(), and sortBy()
- date-utils: fix off-by-one in formatRelative (round instead of floor)
- validator: fix isEmail long-TLD and isUrl port 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