Skip to content

fix(utils): repair failing tests and implement missing utilities - #302

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2214-1787588068
Open

fix(utils): repair failing tests and implement missing utilities#302
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2214-1787588068

Conversation

@stooit

@stooit stooit commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library (60/60 now pass). Only src/ files were changed — no test files and no dependencies were touched.

Changes

  • calculatordivide now throws on a zero divisor instead of returning Infinity.
  • string-utilswordCount collapses runs of consecutive whitespace (trim().split(/\s+/)); truncate implemented: returns input unchanged when within maxLength, otherwise cuts at the last word boundary within budget and appends ... (ellipsis counts toward maxLength), with fallbacks for very small limits and no-space budgets.
  • task-manager — implemented remove (returns true/false), update (guards unknown ids, only applies keys explicitly present), and sortBy (priority high→medium→low, status, and ascending createdAt).
  • date-utils — day diff uses Math.round rather than Math.floor, so 36h correctly reports "2 days ago" (off-by-one fix).
  • validatorisEmail accepts long TLDs (e.g. .museum) and rejects empty labels; isUrl accepts URLs with a port (e.g. http://localhost:3000) while still restricting the protocol to http/https.

Verification

bun test60 pass, 0 fail. tsc --noEmit clean.

Assumptions / notes

  • divide throws a generic Error — the test only asserts .toThrow().
  • sortBy("createdAt") gained an explicit id tiebreaker because add() stamps createdAt to the millisecond; back-to-back adds could otherwise collide and rely on sort stability.

…ports

Implement missing functionality and fix edge-case bugs surfaced by the
test suite:

- calculator: divide now throws on a zero divisor instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; truncate implemented
  with word-boundary cutting and ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy (priority/status/createdAt)
- date-utils: round rather than floor day diffs so 36h reports '2 days ago'
- validator: isEmail accepts long TLDs and rejects empty labels; isUrl accepts
  URLs with a port

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