Skip to content

fix: repair failing tests across utility library - #307

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2222-1787872381
Open

fix: repair failing tests across utility library#307
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2222-1787872381

Conversation

@stooit

@stooit stooit commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across 5 source files. All 60 tests now pass; tsc --noEmit is clean. Only source files were modified — no test files changed, no dependencies added.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity (also catches -0).
  • src/string-utils.tswordCount splits on /\s+/ (collapses consecutive whitespace); implemented truncate to cut at a word boundary with "..." counting toward maxLength, guarding the maxLength <= 3 degenerate case.
  • src/task-manager.ts — implemented remove, update (per-field, avoids clobbering with undefined), and sortBy (priority high>medium>low, createdAt oldest-first; sorts a copy so the internal Map isn't mutated on read).
  • src/date-utils.tsformatRelative day calc uses Math.round(abs(hours)/24) instead of Math.floor, fixing the 36h→"2 days ago" off-by-one and the future-date branch.
  • src/validator.tsisEmail accepts long TLDs ({2,}); isUrl accepts explicit ports (dropped the erroneous port === "" check) while keeping the http/https allowlist.

Assumptions & notes

  • Test files were treated as the source of truth for expected behaviour; changes are minimal to satisfy them.
  • isEmail remains a permissive format check (not full validation) and isUrl accepts any host including internal ones (localhost, link-local). Both match the tests but are not security controls — if either gates a server-side fetch or ingress path, add SSRF/host-allowlist defences and confirmation-link email verification at the call site.

Testing

bun test60 pass / 0 fail.

Implement truncate/remove/update/sortBy, fix wordCount whitespace
splitting, formatRelative day rounding, and email TLD/URL port
validation.
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