Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2232-1786205477
Open

fix: implement missing utilities and fix edge-case bugs#279
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2232-1786205477

Conversation

@stooit

@stooit stooit commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. Final result: 60 pass / 0 fail, tsc --noEmit clean. No test files modified, no dependencies added.

Changes

  • src/calculator.tsdivide throws on division by zero instead of returning a poisoned Infinity/NaN.
  • src/string-utils.tswordCount splits on \s+ (collapses runs of spaces/tabs/newlines); truncate implemented — reserves 3 chars for "...", cuts at a word boundary (falling back to a hard cut when the boundary would lose too much), never exceeds maxLength, handles maxLength <= 3 and negative values.
  • src/task-manager.ts — implemented remove (returns boolean), update (returns false for unknown id, only overwrites explicitly-supplied fields), and sortBy (priority high→medium→low, createdAt oldest-first, status ordering) with exhaustive union handling.
  • src/date-utils.tsformatRelative off-by-one fixed: 36 hours now reads "2 days ago"; symmetric for future dates.
  • src/validator.tsisEmail TLD bound widened to 2–63 chars (accepts .museum); isUrl no longer rejects URLs with an explicit port (http://localhost:3000), keeps http/https scheme allowlist.

Assumptions & notes

  • Fixed only what the tests require, per the task constraints.
  • isEmail/isUrl are format checks only — not deliverability or SSRF/injection defences. If isUrl is ever used to vet server-fetched URLs, loopback/private hosts (now accepted for the test) would need a call-site allowlist. Flagged for a follow-up rather than changed here.
  • Pre-existing 23.6h → "24 hours ago" boundary and sortBy returning live Task references were left as-is, out of scope for this fix.

Test plan

  • bun test → 60 pass / 0 fail
  • tsc --noEmit → clean

- calculator: throw on division by zero
- string-utils: fix wordCount whitespace handling, implement truncate
- task-manager: implement remove/update/sortBy
- date-utils: fix formatRelative off-by-one at day boundary
- validator: widen isEmail TLD bound, accept URLs with 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