Skip to content

fix: repair failing utility library tests#210

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2432-1781546469
Open

fix: repair failing utility library tests#210
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2432-1781546469

Conversation

@stooit

@stooit stooit commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the TypeScript utility library. All 60 tests now pass with no test files modified and no new dependencies added.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") instead of silently returning Infinity.
  • src/date-utils.tsformatRelative uses Math.round for the day diff, fixing an off-by-one (e.g. 36h now reads "2 days ago").
  • src/string-utils.ts — implemented truncate (word-boundary aware, output always ≤ maxLength), wordCount, and slugify.
  • src/task-manager.ts — completed TaskManager.complete() (sets status: "completed" + completedAt, returns true/false) and wired up getByStatus.
  • src/validator.tsisEmail now handles subdomains and long TLDs (e.g. .museum); isUrl rebuilt on new URL() to handle ports, paths, query strings, and fragments.

Verification

  • bun test60 pass, 0 fail.
  • Independent review pass confirmed all changes are genuine implementations (no test-gaming hacks) with no regressions.

Assumptions

  • Division-by-zero throwing (rather than returning a sentinel) matches the test expectations.
  • formatRelative rounding semantics follow the test assertions.
  • No source behaviour outside the failing tests' scope was altered.

- calculator: throw on division by zero instead of returning Infinity
- date-utils: round day diff in formatRelative (off-by-one fix)
- string-utils: implement truncate, wordCount, slugify
- task-manager: complete TaskManager.complete() and getByStatus
- validator: fix isEmail long-TLD/subdomain handling and isUrl port/path support

All 60 tests pass.
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