Skip to content

fix: implement missing utils and fix edge-case bugs to pass all tests#222

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2456-1781973707
Open

fix: implement missing utils and fix edge-case bugs to pass all tests#222
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2456-1781973707

Conversation

@stooit

@stooit stooit commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library. The full suite is now 60 pass / 0 fail, with no test files modified and no new dependencies added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") instead of returning Infinity.
  • src/string-utils.ts
    • wordCount collapses consecutive whitespace (trim().split(/\s+/)) so empty tokens aren't counted.
    • truncate implemented: word-boundary truncation with the ellipsis counted toward maxLength.
  • src/task-manager.ts — implemented/completed remove, update, and sortBy (priority weighting + createdAt oldest-first).
  • src/date-utils.tsformatRelative rounds hours→days (fixes the off-by-one; 36h → "2 days ago").
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts explicit ports (e.g. http://localhost:3000).

Testing

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

Review notes / assumptions

  • Scope was kept to exactly what the tests require, per task constraints.
  • Independent review flagged non-blocking, untested edge cases for potential follow-up (not addressed here to stay in scope): truncate with very small maxLength (≤3), the 12-hour rounding boundary in formatRelative, and a pre-existing in-place mutation in TaskManager.update.

🤖 Generated autonomously

- calculator.divide: throw on division by zero
- string-utils.wordCount: collapse consecutive whitespace
- string-utils.truncate: implement word-boundary truncation with ellipsis
- task-manager: implement remove, update, and sortBy methods
- date-utils.formatRelative: round hours-to-days (fixes off-by-one)
- validator.isEmail: allow long TLDs; isUrl: allow explicit ports
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