Skip to content

fix: repair failing utility tests and implement missing functionality#237

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2444-1783096710
Open

fix: repair failing utility tests and implement missing functionality#237
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2444-1783096710

Conversation

@stooit

@stooit stooit commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

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

Changes by module

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • src/string-utils.tswordCount handles multiple consecutive spaces (trim + split on \s+); truncate implemented to respect word boundaries with the ellipsis counting toward maxLength and handling strings shorter than the ellipsis.
  • src/task-manager.ts — implemented/completed remove (returns false for unknown id), update (title/priority, returns false for unknown id), and sortBy for priority (high → medium → low) and createdAt (oldest first).
  • src/date-utils.ts — fixed formatRelative rounding so 36 hours reads "2 days ago"; the rounded hour value now drives both the < 24 branch guard and the label, so "24 hours ago" can no longer be emitted.
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts host:port URLs (e.g. http://localhost:3000).

Verification

  • bun test → 60 pass, 0 fail, 70 expect() calls.
  • Only the five src/*.ts files changed; no test files touched.

Review notes

Changes were reviewed by a review pass; follow-up polish applied: made the hours/days boundary consistent, fixed a lastSpace >= 0 boundary case in truncate, and removed stale BUG:/TODO: comments.

Assumptions

  • Expected behaviours were inferred directly from the existing (unmodified) test cases.
  • Error message text (e.g. "Division by zero") follows the assertions in the tests.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: fix wordCount for consecutive spaces; implement word-boundary truncate with ellipsis
- task-manager: implement remove, update, and sortBy (priority/createdAt)
- date-utils: fix formatRelative rounding so 36h reads '2 days ago' and no '24 hours ago' output
- validator: accept long TLDs in isEmail and host:port URLs in isUrl
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