Skip to content

fix: repair edge-case bugs and implement missing utility functions - #271

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2174-1785429406
Open

fix: repair edge-case bugs and implement missing utility functions#271
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2174-1785429406

Conversation

@stooit

@stooit stooit commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the utility library (44 → 60 pass / 0 fail). Only the 5 source files were changed — no test files modified, no dependencies added, clean tsc --noEmit.

Changes

  • calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • string-utils.tswordCount collapses consecutive whitespace ("hello world" → 2); implemented truncate with word-boundary logic where "..." counts toward maxLength, returning the string unchanged when within the limit and handling maxLength <= 3 without exceeding it.
  • task-manager.ts — implemented remove (returns true/false), update (title/description/priority, returns true/false), and sortBy (priority high > medium > low, plus createdAt/status, relying on stable sort for insertion-order tiebreaks).
  • date-utils.ts — fixed formatRelative off-by-one: 36h ago now rounds to "2 days ago"; rounding applied on the magnitude so past/future are symmetric.
  • validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts host-only and ported URLs (e.g. http://localhost:3000).

Verification

  • bun test → 60 pass / 0 fail (70 expect() calls)
  • npx tsc --noEmit → clean
  • Reviewed by a review pass; three latent correctness issues surfaced (truncate length contract, formatRelative future-diff asymmetry, fragile numeric-id tiebreak) were all addressed even though no current test covers them.

Assumptions

  • truncate spec (word boundary, ellipsis-in-budget) inferred from the test file's expected values and the source TODO comment.
  • sortBy priority ordering (high > medium > low) taken from the test expectations.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate
  with word-boundary logic and ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy methods
- date-utils: fix formatRelative off-by-one via symmetric magnitude rounding
- validator: relax isEmail TLD length and accept host-only/ported URLs in isUrl

Fixes 16 failing tests (44 -> 60 pass). No test files or dependencies changed.
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