Skip to content

fix: repair all failing utility functions#239

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2474-1783268938
Open

fix: repair all failing utility functions#239
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2474-1783268938

Conversation

@stooit

@stooit stooit commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. All 60 tests now pass (0 fail).

Changes

  • calculator.tsdivide now throws Error("Division by zero") instead of returning Infinity.
  • date-utils.tsformatRelative uses Math.round (was Math.floor) so 36 hours ago rounds to "2 days ago".
  • string-utils.ts — implemented truncate (returns unchanged within limit, truncates at word boundary, ellipsis counts toward maxLength, handles strings shorter than the ellipsis); fixed wordCount to collapse consecutive spaces.
  • task-manager.ts — implemented/completed remove (false for unknown id), update (title & priority, false for unknown id), and sortBy (priority high>medium>low, createdAt oldest first).
  • validator.ts — fixed isEmail for long TLDs and isUrl for URLs with a port (e.g. http://localhost:3000).

Verification

bun test -> 60 pass, 0 fail.

Assumptions & notes

  • Scope kept strictly to what the tests require, per task constraints. No test files modified; no dependencies added.
  • A review flagged that the isEmail/isUrl patterns remain permissive for some structurally-odd inputs not covered by tests. Tightening them was deliberately left out to avoid regressing passing tests and to respect the "fix only what the tests require" constraint.

- calculator: divide now throws on division by zero instead of returning Infinity
- date-utils: formatRelative uses Math.round so 36h rounds to 2 days
- string-utils: implement truncate (word boundary, ellipsis in maxLength) and fix wordCount for consecutive spaces
- task-manager: implement remove, update, and sortBy methods
- validator: fix isEmail long-TLD and isUrl port handling
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