Skip to content

fix: repair failing utility-library tests across 5 modules#246

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-4664-1783873501
Open

fix: repair failing utility-library tests across 5 modules#246
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-4664-1783873501

Conversation

@stooit

@stooit stooit commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the TypeScript utility library. All 60 tests now pass, 0 failures. No test files were modified and no new dependencies were added.

Fixes by module

  • src/calculator.tsdivide now throws Error("Division by zero") on a zero divisor instead of returning Infinity.
  • src/string-utils.ts — implemented truncate (word-boundary truncation with ellipsis counting toward maxLength, handling strings shorter than the ellipsis); fixed wordCount to collapse multiple consecutive spaces via trim().split(/\s+/).
  • src/task-manager.ts — implemented/completed remove, update, and sortBy (priority high→medium→low, createdAt oldest-first) per the test contract.
  • src/date-utils.ts — fixed off-by-one in formatRelative by rounding days with Math.round instead of Math.floor (36h now correctly reads "2 days ago").
  • src/validator.tsisEmail now allows long TLDs (e.g. .museum); isUrl uses the URL parser so hosts with ports (e.g. http://localhost:3000) validate.

Verification

  • bun test → 60 pass / 0 fail.
  • Independent review confirmed all fixes address root causes (no test-gaming / hardcoding) and honour the no-test-edits / no-new-deps constraints.

Assumptions

  • formatRelative day rounding uses Math.round, consistent with the test expectation at the 36h boundary.
  • isUrl accepts only http:/https: protocols (matches existing test coverage).

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: implement truncate (word-boundary + ellipsis), fix wordCount for consecutive spaces
- task-manager: implement remove/update/sortBy methods per test contract
- date-utils: fix off-by-one in formatRelative (Math.round day rounding)
- validator: allow long TLDs in isEmail; use URL parser in isUrl to accept ports

All 60 tests pass, 0 failures. No test files modified, no new dependencies.
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