Skip to content

fix: repair 16 failing tests across utility library - #310

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2171-1788106607
Open

fix: repair 16 failing tests across utility library#310
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2171-1788106607

Conversation

@stooit

@stooit stooit commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously failing tests across 5 source files. 60/60 tests pass, tsc --noEmit clean. No test files modified, no dependencies added.

Fixes

  • calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • string-utils.tswordCount collapses consecutive-whitespace runs (/\s+/); implemented truncate to cut at a word boundary with "..." counting toward maxLength, returning the string unchanged when within limit.
  • task-manager.ts — implemented remove (true/false on found), update (title/description/priority, true/false on found), and sortBy (priority high>medium>low, createdAt oldest-first, plus status ordering).
  • date-utils.tsformatRelative off-by-one fixed by rounding hours-to-days (Math.round), so 36h → "2 days ago"; symmetry preserved for future dates.
  • validator.tsisEmail accepts long TLDs (e.g. .museum) while still rejecting a@b..com; isUrl accepts URLs with ports (e.g. http://localhost:3000).

Verification

  • bun test: 60 pass, 0 fail
  • tsc --noEmit: clean
  • Reviewed via review subagent — verdict COMMENT, no blockers.

Assumptions

  • sortBy("status") order (in_progress > pending > completed) and the numeric id tiebreak for same-millisecond createdAt ties are not exercised by tests; chosen as reasonable defaults.
  • Review raised non-blocking suggestions (truncate whitespace-boundary detection, update clearing optional fields, SSRF/credential-URL considerations for isUrl) that go beyond what the tests require; left out per the "fix only what the tests require" constraint.

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses whitespace runs; implement truncate at word boundary with ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy (priority high>medium>low, createdAt oldest-first)
- date-utils: formatRelative rounds hours (Math.round) fixing 36h off-by-one
- 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