Skip to content

fix: repair failing tests across calculator, string, date, task, and validation utils - #327

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2179-1788936450
Open

fix: repair failing tests across calculator, string, date, task, and validation utils#327
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2179-1788936450

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously failing tests (now 60 pass / 0 fail) across five utility modules. No test files were modified and no dependencies were added — only the source functions the tests exercise were changed.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0, instead of silently returning Infinity.
  • src/string-utils.tswordCount splits on /\s+/ (collapses consecutive whitespace, returns 0 for whitespace-only); truncate implemented with word-boundary back-off and ellipsis counting toward maxLength, never exceeding it.
  • src/task-manager.ts — implemented remove (hit/miss), update (safe partial updates), and sortBy (priority/status rank maps, oldest-first on createdAt).
  • src/date-utils.tsformatRelative rounds the day count, fixing the off-by-one (36h → "2 days"); past/future branches symmetric.
  • src/validator.tsisEmail accepts TLDs > 4 chars; isUrl accepts host:port URLs while keeping the http/https allowlist.

Verification

  • bun test → 60 pass, 0 fail
  • tsc --noEmit → clean
  • Changes independently reviewed; a date-utils rounding regression and a truncate word-boundary over-fit found in review were corrected before commit.

Assumptions / notes

  • isEmail remains a permissive shape check, not RFC 5322 validation.
  • test/ left untouched per the brief; a couple of untested edge paths noted for follow-up, out of scope here.

…ion utils

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate
  with word-boundary back-off and ellipsis counting toward maxLength
- task-manager: implement remove/update/sortBy with partial-update safety
- date-utils: formatRelative rounds day count (fixes off-by-one at 36h)
- validator: isEmail accepts longer TLDs; isUrl accepts host:port URLs
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