Skip to content

fix: repair failing utility tests and implement missing functions#249

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2433-1784133422
Open

fix: repair failing utility tests and implement missing functions#249
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2433-1784133422

Conversation

@stooit

@stooit stooit commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library and implements the missing/stubbed functions. All 60 tests now pass (0 failures). No test files were modified and no dependencies were added.

Changes

File Fix
src/calculator.ts divide now throws Error("Division by zero") when the divisor is 0 (was returning Infinity).
src/string-utils.ts wordCount collapses consecutive whitespace (trim().split(/\s+/)); implemented truncate with word-boundary truncation where the "..." ellipsis counts toward maxLength.
src/task-manager.ts Implemented remove (returns false for unknown id), update (applies changes, false for unknown id), and sortBy (priority high→low, createdAt oldest-first).
src/validator.ts isEmail accepts long TLDs (e.g. .museum); isUrl accepts URLs with an explicit port (e.g. http://localhost:3000).
src/date-utils.ts formatRelative rounds the day count instead of flooring, fixing the off-by-one (36h → "2 days ago").

Also removed now-stale // BUG: comments that described the just-fixed defects.

Testing

bun test60 pass / 0 fail (70 assertions).

Assumptions

  • sortBy("priority") orders high→medium→low and sortBy("createdAt") orders oldest-first, matching the tests.
  • truncate treats the 3-char ellipsis as part of the maxLength budget.
  • Per the "fix only what the tests require" constraint, untested edge cases were intentionally left unchanged to avoid scope creep.

- calculator: divide now throws on division by zero
- string-utils: wordCount handles consecutive spaces; implement truncate
- task-manager: implement remove, update, and sortBy
- validator: isEmail accepts long TLDs; isUrl accepts URLs with ports
- date-utils: formatRelative rounds days (fixes off-by-one)
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