Skip to content

fix: repair all failing tests across utility library - #291

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2104-1787004741
Open

fix: repair all failing tests across utility library#291
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2104-1787004741

Conversation

@stooit

@stooit stooit commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across 5 source files. 60 pass / 0 fail, tsc --noEmit clean. No test files or dependencies modified.

Changes

  • calculatordivide now throws on division by zero (was returning Infinity).
  • string-utilswordCount collapses consecutive whitespace (splits on /\s+/ after trim); truncate implemented (reserves 3 chars for ellipsis, cuts at word boundary, output always <= maxLength).
  • task-manager — implemented remove (returns delete boolean), update (partial updates, false for unknown id), and sortBy (priority high→medium→low, status ordering, createdAt oldest-first). Copies before in-place sort so list() order is preserved.
  • date-utilsformatRelative now rounds abs(diffHours)/24, fixing the off-by-one at the 36-hour boundary (36h → "2 days ago").
  • validatorisEmail regex widened for multi-level subdomains and TLDs longer than 4 chars (and now correctly rejects empty labels like user@example..com), with a 254-char cap; isUrl no longer rejects URLs with an explicit port (http://localhost:3000).

Verification

  • bun test → 60 pass / 0 fail (70 expect() calls, 5 files)
  • tsc --noEmit clean
  • Independent review pass: no blockers. Confirmed the relaxed email regex is not ReDoS-vulnerable (disjoint character classes on ., linear scaling, plus the 254-char cap).

Assumptions / notes

  • Breaking change: divide(x, 0) now throws instead of returning Infinity — required by the test spec.
  • truncate with maxLength <= 3 hard-slices without an ellipsis (not pinned by any test).
  • Non-blocking edge cases surfaced by review but outside test scope (left unchanged): truncate can split a UTF-16 surrogate pair when the cut lands mid-pair; update can't clear the optional description field via { description: undefined }. Can follow up if desired.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: fix wordCount for consecutive whitespace; implement truncate
- task-manager: implement remove, update, and sortBy
- date-utils: fix off-by-one in formatRelative day rounding
- validator: widen isEmail for long/multi-level TLDs; fix isUrl port handling

All 60 tests pass. No test files or dependencies modified.
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