Skip to content

fix: repair all failing tests across utility modules - #334

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2292-1788997583
Open

fix: repair all failing tests across utility modules#334
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2292-1788997583

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests (now 60/60 pass) across the utility library, implementing missing functionality and repairing edge-case bugs. No test files modified, no dependencies added. tsc --noEmit is clean.

Changes by module

  • calculator.tsdivide now throws on a zero divisor (b === 0, also catches -0) instead of returning Infinity/NaN.
  • string-utils.tswordCount uses trim().split(/\s+/) so consecutive whitespace no longer produces empty entries. truncate implemented: cuts at a word boundary with "..." counting toward maxLength, returns unchanged when within limit, never exceeds maxLength.
  • task-manager.ts — implemented remove (boolean), update (returns false for unknown id; only applies provided keys), and sortBy (priority high→medium→low, createdAt oldest first). sortBy throws on unknown field with a never exhaustiveness guard.
  • date-utils.ts — fixed off-by-one in formatRelative: Math.round(abs(diffHours)/24) so 36h maps to "2 days ago"; future dates stay symmetric.
  • validator.tsisEmail accepts arbitrary subdomain depth and long TLDs (e.g. .museum); isUrl accepts URLs with ports (e.g. http://localhost:3000) while still rejecting non-http(s) protocols.

Verification

  • bun test60 pass, 0 fail
  • bunx tsc --noEmit → clean

Reviewer notes / assumptions

  • divide is a semver-major behaviour change for consumers relying on Infinity/NaN propagation. Required by the test suite; flagged for changelog.
  • update's !== undefined guard means description cannot be cleared via undefined — kept as the intentional convention.
  • isEmail/isUrl are format checks, not trust-boundary controls. localhost/internal IPs accepted by design (unchanged from prior behaviour); add SSRF protection separately if a URL feeds a server-side fetch.

🤖 Generated with QuantCode

- calculator: divide throws on zero divisor instead of returning Infinity/NaN
- string-utils: wordCount collapses consecutive whitespace; implement truncate
  with word-boundary cutting and ellipsis counted toward maxLength
- task-manager: implement remove/update/sortBy; fail loudly on unknown sort field
- date-utils: fix off-by-one in formatRelative day rounding (36h -> 2 days ago)
- validator: isEmail accepts long TLDs/subdomains; isUrl accepts ports
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