Skip to content

fix: repair failing tests across utility library#207

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2498-1781408025
Open

fix: repair failing tests across utility library#207
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2498-1781408025

Conversation

@stooit

@stooit stooit commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the TypeScript utility library. All 60 tests now pass; no previously-passing tests were broken. No test files modified, no new dependencies added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0, instead of returning Infinity.
  • src/string-utils.tswordCount uses trim().split(/\s+/) so consecutive spaces don't yield empty tokens; truncate ellipsis accounting corrected.
  • src/task-manager.ts — completed missing/incomplete TaskManager methods (incl. completeTask setting completedAt).
  • src/date-utils.tsformatRelative off-by-one fixed (Math.round instead of Math.floor), so e.g. 36 hours ago → "2 days ago".
  • src/validator.tsisEmail now accepts long TLDs (e.g. user@example.museum); isUrl now accepts URLs with ports (e.g. http://localhost:3000).

Verification

  • bun test60 pass, 0 fail (70 expect() calls across 5 files).
  • Independent review pass: approved. One non-blocking nit noted — truncate with maxLength ≤ 2 hard-slices without an ellipsis; not covered by tests and behaviour is unspecified, so left as-is per the "fix only what tests require" constraint.

Assumptions

  • The email/URL regexes are intentionally permissive to satisfy the test contract; no stricter RFC validation was introduced since tests don't require it.
  • completeTask sets completedAt to wall-clock new Date() rather than an injected timestamp.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: fix wordCount whitespace handling and truncate ellipsis logic
- task-manager: complete missing/incomplete TaskManager methods
- date-utils: fix formatRelative off-by-one (Math.round instead of floor)
- validator: isEmail accepts long TLDs; isUrl accepts URLs with ports

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