Skip to content

fix: implement missing utility functions and fix edge-case bugs - #267

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2376-1785093683
Open

fix: implement missing utility functions and fix edge-case bugs#267
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2376-1785093683

Conversation

@stooit

@stooit stooit commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the TypeScript utility library. 60 pass, 0 fail after the change (was 44 pass / 16 fail), tsc --noEmit clean, no test files modified, no new dependencies.

Changes by file

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0.
  • src/string-utils.tswordCount handles multiple consecutive spaces; truncate implemented (returns unchanged when within limit, truncates at a word boundary, "..." counts toward maxLength, handles strings shorter than the ellipsis).
  • src/task-manager.ts — implemented the missing remove, update, and sortBy methods (sort by priority high→medium→low, and by createdAt oldest-first).
  • src/date-utils.ts — fixed an off-by-one in formatRelative day rounding (36 hours now reports "1 day ago").
  • src/validator.tsisEmail accepts long TLDs; isUrl accepts URLs with an explicit port.

Verification

  • bun test -> 60 pass, 0 fail, stable across repeated runs.
  • Independent code review: implementations are general (not tuned to specific assertions), no regressions, no test files touched.

Assumptions

  • Scope limited to "fix only what the tests require," per the task. Untested edge cases (e.g. truncate with a negative maxLength) were left as-is to avoid changing behaviour beyond the test contract.

Fixes 16 failing tests across the library:
- calculator: divide now throws on division by zero
- string-utils: fix wordCount for consecutive spaces; implement truncate
- task-manager: implement remove, update, and sortBy
- date-utils: fix off-by-one in formatRelative day rounding
- validator: fix isEmail long-TLD and isUrl port edge cases
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