Skip to content

fix: implement missing utils and correct 5 logic bugs - #290

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2282-1786982966
Open

fix: implement missing utils and correct 5 logic bugs#290
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2282-1786982966

Conversation

@stooit

@stooit stooit commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the 5 source files. bun test now reports 60 pass / 0 fail (was 44 pass / 16 fail), and tsc --noEmit is clean. No test files or dependencies were modified.

Changes

  • src/calculator.tsdivide now throws on division by zero (also covers -0) instead of returning Infinity.
  • src/date-utils.tsformatRelative day calc uses Math.round(Math.abs(diffHours) / 24), fixing the off-by-one so 36h reports "2 days ago" (past and future symmetric).
  • src/validator.tsisEmail TLD quantifier widened {2,4}{2,} (accepts long TLDs like .museum); isUrl drops the empty-port requirement so http://localhost:3000 validates, while keeping the protocol allow-list.
  • src/string-utils.tswordCount uses trim().split(/\s+/) for consecutive spaces; truncate implemented with ellipsis counted toward maxLength and word-boundary cutting.
  • src/task-manager.ts — implemented remove (returns boolean), update (guarded key-wise assignment, returns boolean), and sortBy (priority and createdAt ordering on a sorted copy, preserving insertion order via stable sort).

Verification

  • bun test → 60 pass / 0 fail
  • tsc --noEmit → exit 0
  • Diff reviewed: no correctness blockers found.

Assumptions / notes

  • Scoped strictly to what the tests require (per task constraints). Review flagged a few untested edge cases (negative maxLength, clearing an optional description, sortBy with an unrecognised field) — left out of scope as no test exercises them and the task said to fix only what tests require.
  • isUrl is a format validator, not an SSRF guard — documented in its docstring.

Implements truncate and TaskManager.remove/update/sortBy, and fixes
wordCount whitespace handling, formatRelative day rounding, isEmail
TLD length, isUrl port acceptance, and divide-by-zero handling.

Makes all 60 tests pass (was 44 pass / 16 fail). Only source files
changed; no test files or dependencies modified.
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