Skip to content

fix: pass all failing tests in utility library#231

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2513-1782694641
Open

fix: pass all failing tests in utility library#231
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2513-1782694641

Conversation

@stooit

@stooit stooit commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across 5 source files. The full suite now passes: 60 pass / 0 fail. No test files were modified and no dependencies were added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") instead of returning Infinity.
  • src/string-utils.tswordCount splits on /\s+/ to handle consecutive spaces; truncate implemented (returns input when within limit, otherwise cuts at the last word boundary with the ellipsis counted toward maxLength, and handles strings shorter than the ellipsis).
  • src/task-manager.ts — implemented the missing remove, update, and sortBy methods (sortBy orders priority high→medium→low and createdAt oldest-first; remove/update return false for unknown ids).
  • src/validator.tsisEmail now accepts long TLDs (e.g. user@example.museum); isUrl accepts URLs with ports (e.g. http://localhost:3000).
  • src/date-utils.ts — fixed formatRelative rounding so 36h reads "2 days ago" and the hours branch uses Math.floor, so it can never emit "24 hours ago".

Testing

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

Assumptions

  • Treated the test files as the authoritative spec for each function's contract.
  • Applied one out-of-strict-scope but trivial correctness fix (the Math.floor 24h-boundary guard in formatRelative) surfaced during review; it changes no tested behaviour.

🤖 Generated autonomously.

…ests

- calculator: divide now throws on division by zero
- string-utils: wordCount handles consecutive spaces; truncate implemented with word-boundary cut and ellipsis accounting
- task-manager: implement remove, update, and sortBy (priority/createdAt)
- validator: isEmail accepts long TLDs; isUrl accepts URLs with ports
- date-utils: fix formatRelative rounding (off-by-one + 24h boundary)
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