Skip to content

fix: repair all failing tests in utility library - #258

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2465-1784824598
Open

fix: repair all failing tests in utility library#258
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2465-1784824598

Conversation

@stooit

@stooit stooit commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the TypeScript utility library. All 60 tests now pass (0 fail), and no previously-passing tests were broken. No test files were modified and no dependencies were added.

Changes by file

  • src/calculator.tsdivide now throws Error("Division by zero") instead of returning Infinity.
  • src/string-utils.tswordCount now splits on /\s+/ (handles multiple/leading/trailing spaces); implemented truncate with word-boundary trimming, and correct handling when maxLength <= 3 (slices to maxLength rather than returning the full string).
  • src/task-manager.ts — implemented the missing remove (returns boolean), update (returns boolean, Object.assign of changes), and sortBy (priority weight map, createdAt ascending, status via localeCompare).
  • src/date-utils.tsformatRelative uses Math.round instead of Math.floor for the days bucket (36h now rounds to "2 days ago").
  • src/validator.tsisEmail TLD quantifier relaxed from {2,4} to {2,} (allows TLDs like .museum); isUrl now checks only that the protocol is http/https.

Verification

  • bun test → 60 pass / 0 fail.
  • Changes were plan-driven, implemented, and independently reviewed for correctness beyond the test assertions.

Assumptions

  • truncate's ellipsis is the literal "..." (3 chars) counted within maxLength.
  • sortBy("createdAt") sorts oldest-first; unknown field falls back to status ordering.

- calculator: throw on division by zero instead of returning Infinity
- string-utils: fix wordCount whitespace splitting; implement truncate with word-boundary and small-maxLength handling
- task-manager: implement remove, update, and sortBy methods
- date-utils: use Math.round for relative day rounding (36h -> 2 days)
- validator: allow TLDs >4 chars in isEmail; simplify isUrl to protocol check
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