Skip to content

fix: repair edge-case bugs and implement missing utility functions - #284

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2163-1786551804
Open

fix: repair edge-case bugs and implement missing utility functions#284
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2163-1786551804

Conversation

@stooit

@stooit stooit commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests in the utility library (now 60 pass / 0 fail) by repairing edge-case bugs and implementing missing functions. Only the 5 source files were touched — no test files modified, no dependencies added.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of silently returning Infinity.
  • src/string-utils.ts
    • wordCount trims and splits on \s+, so consecutive/leading/trailing whitespace collapses correctly.
    • truncate implemented — truncates at a word boundary, ellipsis (...) counts toward maxLength, returns unchanged when within the limit.
  • src/task-manager.ts — implemented remove, update (partial field updates), and sortBy (priority high>medium>low, createdAt oldest-first, status).
  • src/date-utils.tsformatRelative day bucket uses Math.round instead of Math.floor, fixing the 36h → "2 days ago" off-by-one.
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum); isUrl accepts URLs with a port (e.g. http://localhost:3000).

Verification

  • bun test: 60 pass, 0 fail across 5 files.
  • tsc --noEmit: clean.
  • Independent review confirmed no regressions in behaviour outside test coverage.

Assumptions / notes

  • sortBy("status") orders pending → in_progress → completed (matches the Status union declaration order); not covered by a test.
  • Two latent edge cases in new code, out of scope for the tests and left as-is per "fix only what the tests require": truncate with a negative maxLength, and update clearing an optional description via undefined.

🤖 Generated with QuantCode

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: wordCount collapses consecutive whitespace; implement truncate at word boundary with ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy (priority/createdAt/status)
- date-utils: formatRelative uses Math.round for day bucket (fixes 36h off-by-one)
- validator: isEmail accepts long TLDs; isUrl accepts URLs with a port

All 60 tests pass.
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