Skip to content

fix: implement missing utils and fix edge-case bugs to pass tests - #330

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2166-1788941142
Open

fix: implement missing utils and fix edge-case bugs to pass tests#330
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2166-1788941142

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across 5 source files with no test-file changes and no new dependencies. Full suite now: 60 pass / 0 fail; bunx tsc --noEmit exits 0.

Changes

  • calculator.tsdivide throws Error("Division by zero") when b === 0 instead of returning Infinity.
  • string-utils.tswordCount splits on /\s+/ against the trimmed string so consecutive whitespace collapses; implemented truncate (returns unchanged when str.length <= maxLength, reserves 3 chars for "..." so output never exceeds maxLength, cuts back to the last word boundary within budget, hard-slices a single overflowing word).
  • date-utils.ts — fixed off-by-one in diffDays by taking Math.abs before Math.round.
  • validator.ts — broadened isEmail (arbitrary-depth subdomains, 2+ char TLDs, labels can't start/end with hyphen); fixed isUrl port handling while keeping the http/https scheme allowlist (still rejects javascript: etc.).
  • task-manager.ts — completed remove (boolean semantics), update (returns false for unknown id, only applies provided fields), and sortBy (priority/status rank maps + createdAt timestamp compare, stable-sort for ties).

Testing

  • bun test → 60 pass, 0 fail
  • bunx tsc --noEmit → exit 0

Notes / assumptions

  • sortBy("createdAt") relies on stable sort for same-millisecond ties (passes tests).
  • The isUrl scheme allowlist is only protective if callers route user-supplied URLs through it.

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate
- date-utils: fix off-by-one in diffDays for future dates (abs before round)
- validator: broaden isEmail regex; fix isUrl port handling (keep scheme allowlist)
- task-manager: implement/complete remove, update, and sortBy
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