Skip to content

fix: repair 16 failing utility-library tests - #332

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2182-1788970776
Open

fix: repair 16 failing utility-library tests#332
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2182-1788970776

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across 5 modules so the full suite passes (60 pass / 0 fail). No test files were modified and no dependencies were added — only the behaviour the tests require was changed.

Changes

  • src/calculator.tsdivide now guards against a zero divisor (throws). The b === 0 check also catches -0, which previously produced -Infinity.
  • src/string-utils.ts
    • wordCount now trims and splits on /\s+/, correctly counting words separated by consecutive spaces (and tabs/newlines).
    • truncate implemented: returns the string unchanged when str.length <= maxLength; otherwise truncates at a word boundary with "..." counting toward maxLength.
  • src/task-manager.ts — implemented remove (delete by id), update (partial field update, returns false if not found), and sortBy (returns a sorted copy, leaving internal insertion order intact).
  • src/date-utils.ts — fixed off-by-one in relative-day formatting by rounding the (absolute) day difference instead of flooring, so 36h correctly reads "2 days ago" and future dates stay symmetric.
  • src/validator.tsisEmail broadened to accept valid multi-label domains / longer TLDs while still rejecting malformed labels; isUrl now accepts URLs with explicit ports (e.g. http://localhost:3000) while retaining the protocol allowlist.

Verification

  • bun test → 60 pass / 0 fail
  • bunx tsc --noEmit → clean
  • Independent review pass: no blocking correctness issues; remaining notes concern untested edge cases and pre-existing main behaviour, left unchanged per the task scope ("fix only what the tests require").

Assumptions

  • Scope limited to what the tests require; untested edge cases (e.g. negative maxLength, clearing an optional description via update) were intentionally left as-is to avoid changing unverified behaviour.

- calculator: guard divide against zero (and -0) divisor
- string-utils: fix wordCount for consecutive/whitespace runs; implement truncate at word boundary with ellipsis in budget
- task-manager: implement remove/update/sortBy
- date-utils: fix off-by-one in relative-day formatting (round + abs)
- validator: broaden isEmail TLD/labels; allow ports in isUrl while keeping protocol allowlist
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