Skip to content

fix: implement missing utilities and fix edge-case bugs - #347

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2206-1789921041
Open

stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2206-1789921041

Conversation

@stooit

@stooit stooit commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes all 16 previously failing tests pass (60/60 now green, tsc --noEmit clean) by implementing missing functions and fixing edge-case bugs across the utility library. No test files modified, no new dependencies.

Changes

  • calculator.divide — throws on division by zero (previously returned Infinity/NaN).
  • string-utils — implemented truncate (word-boundary cut, "..." counted toward maxLength); fixed wordCount to collapse consecutive whitespace via trim().split(/\s+/).
  • task-manager — implemented remove (delegates to Map.delete), update (applies only defined fields), and sortBy (priority desc, createdAt asc with numeric-id tiebreak, status lifecycle order).
  • date-utils.formatRelative — fixed off-by-one in the days branch (Math.round(Math.abs(diffHours)/24) instead of Math.floor); now also symmetric for future dates.
  • validator — relaxed isEmail TLD quantifier to {2,} (accepts .museum etc.); dropped the port clause from isUrl (accepts http://localhost:3000).

Verification

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

Assumptions

  • divide now throwing on zero is a behavioural change required by the test; documented here as it affects callers relying on Infinity.
  • truncate omits the ellipsis when maxLength <= 3 (no room for it).

Reviewer notes (non-blocking, out of test scope)

  • sortBy has no runtime default guard — an out-of-union field would return undefined at runtime for JS callers (tsc-safe since the switch is exhaustive).
  • update(id, { description: undefined }) does not clear the field (uses !== undefined guard).
  • isUrl now accepts internal hosts (localhost, link-local) — host allowlisting belongs at the call site if used to gate outbound fetches (SSRF consideration).

🤖 Generated with QuantCode Agent

- calculator.divide: throw on division by zero
- string-utils: implement truncate (word-boundary, ellipsis in maxLength) and fix wordCount for consecutive whitespace
- task-manager: implement remove, update, and sortBy
- date-utils.formatRelative: fix off-by-one in days branch (round instead of floor)
- validator: relax isEmail TLD quantifier; allow ports/localhost in isUrl

All 60 tests pass; tsc --noEmit clean.
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