Skip to content

fix: repair failing utility tests across 5 modules#198

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2450-1780881546
Open

fix: repair failing utility tests across 5 modules#198
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2450-1780881546

Conversation

@stooit

@stooit stooit commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

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

Fixes

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0 instead of returning Infinity.
  • src/string-utils.tswordCount splits on /\s+/ to collapse consecutive whitespace; truncate implemented (returns unchanged within limit, truncates at word boundary, ellipsis counts toward maxLength, handles strings shorter than the ellipsis).
  • src/task-manager.ts — implemented remove (returns false for unknown id), update (title/priority, returns false for unknown id), and sortBy (priority high→medium→low; createdAt oldest first).
  • src/date-utils.ts — fixed off-by-one in formatRelative: day count now rounds correctly so exactly 36 hours reads "2 days ago".
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts URLs with a port (e.g. http://localhost:3000).

Verification

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

Assumptions / notes

  • date-utils.formatRelative: the fix uses Math.round on the day count. This satisfies the test and shifts the hours→days display boundary. No test covers the 12-23h range; left minimal per the "fix only what the tests require" constraint.
  • string-utils.truncate: when maxLength <= ellipsis length, a raw slice (no ellipsis) is returned. This path is untested; chosen as a reasonable fallback without expanding scope.

🤖 Generated with QuantCode Agent

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate
- task-manager: implement remove, update, and sortBy methods
- date-utils: fix off-by-one in formatRelative day rounding
- validator: isEmail accepts long TLDs; isUrl accepts URLs with 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