Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2174-1788020201
Open

fix: implement missing utilities and fix edge-case bugs#309
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2174-1788020201

Conversation

@stooit

@stooit stooit commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across 5 source files. All 60 tests now pass and tsc --noEmit is clean under strict: true. No test files modified, no dependencies added.

Changes

  • calculator.tsdivide now throws on a zero divisor (was returning Infinity); guard catches both 0 and -0.
  • string-utils.tswordCount splits on /\s+/ against the trimmed string so runs of whitespace collapse to one delimiter; implemented truncate (word-boundary cut with "..." counting toward maxLength, unchanged when it already fits).
  • task-manager.ts — implemented remove, update, and sortBy (priority high>medium>low, createdAt oldest first).
  • date-utils.tsformatRelative uses Math.round instead of Math.floor, so 36h rounds to "2 days ago".
  • validator.tsisEmail TLD quantifier relaxed {2,4}{2,} to accept long TLDs (e.g. .museum); isUrl no longer rejects URLs with ports.

Verification

  • bun test: 60 pass / 0 fail
  • tsc --noEmit: clean
  • Reviewed: fixes confirmed correctly scoped, no regression against the 44 previously-passing tests (verified empirically against HEAD across adversarial inputs).

Assumptions / notes (not pinned by tests)

  • update clears description when passed {description: undefined} (uses "description" in changes); title/priority use !== undefined to respect their non-optional types.
  • sortBy("status") has no test coverage — chose workflow order pending → in_progress → completed.
  • sortBy("createdAt") ties rely on stable sort + Map insertion order (ES2019 guarantees stability).
  • Reviewer flagged a pre-existing edge case: truncate with a negative/NaN maxLength is unguarded. No caller passes negative values and it is untested, so left out of scope per "fix only what the tests require".

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate at word boundary with ellipsis
- task-manager: implement remove, update, and sortBy
- date-utils: formatRelative uses Math.round so 36h rounds to 2 days ago
- validator: isEmail accepts long TLDs; isUrl accepts URLs with ports

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