Skip to content

fix: repair failing utility tests and implement missing functions - #318

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2175-1788384003
Open

fix: repair failing utility tests and implement missing functions#318
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2175-1788384003

Conversation

@stooit

@stooit stooit commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests (now 60/60 pass) by repairing edge-case bugs and implementing missing functions across the utility library. No test files modified, no dependencies added — only src/ touched.

Changes

  • calculatordivide now throws on a zero divisor instead of silently returning Infinity (also catches -0).
  • validatorisEmail accepts long TLDs (e.g. .museum) with a 254-char length guard; isUrl no longer rejects URLs with a port (e.g. http://localhost:3000) while still allow-listing http(s).
  • date-utils — day-diff rounds instead of flooring, fixing the off-by-one so 36h reads as "2 days ago".
  • string-utilswordCount collapses runs of whitespace (spaces/tabs/newlines); truncate implemented so the ellipsis counts toward maxLength, cuts at a word boundary, and never returns content-free output (including on leading whitespace).
  • task-manager — implemented remove (returns removed/not-found bool), update (applies only present keys; required fields ignore explicit undefined, optional description can be cleared), and sortBy (priority high>medium>low, createdAt oldest-first; returns a sorted copy leaving internal order intact).

Verification

  • bun test → 60 pass / 0 fail
  • tsc --noEmit → clean
  • Independent review pass: no blockers; the truncate leading-whitespace content-loss edge case flagged in review was fixed in a follow-up commit.

Assumptions

  • sortBy("status") is not covered by any test; ordered in_progress > pending > completed (active work first). Documented as a judgement call — worth confirming intent.

- calculator: divide throws on zero divisor instead of returning Infinity
- validator: isEmail accepts long TLDs (.museum); isUrl accepts URLs with ports
- date-utils: round day diff so 36h reads as 2 days (off-by-one fix)
- string-utils: wordCount collapses runs of whitespace; implement truncate
  (ellipsis counts toward maxLength, cuts at word boundary, no content loss
  on leading whitespace)
- task-manager: implement remove/update/sortBy (priority + createdAt ordering)
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