Skip to content

fix: make all tests pass — implement missing utilities and fix edge-case bugs - #269

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2511-1785171068
Open

fix: make all tests pass — implement missing utilities and fix edge-case bugs#269
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2511-1785171068

Conversation

@stooit

@stooit stooit commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library. All 60 tests now pass (bun test), tsc --noEmit is clean, and no previously-passing tests were broken.

Changes

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity/NaN.
  • src/date-utils.ts — Fixed the off-by-one / rounding-overflow bug in formatRelative. Buckets are chosen after rounding, so top-of-bucket values roll up correctly (e.g. 59.6 min → "1 hour ago", 23.6 h → "1 day ago") instead of emitting "60 minutes ago".
  • src/string-utils.ts — Implemented truncate (word-boundary truncation with "..." counting toward maxLength; unchanged when str.length <= maxLength). Fixed wordCount for consecutive spaces.
  • src/task-manager.ts — Implemented remove, update, and sortBy (priority high→medium→low; createdAt oldest-first). remove/update return false for unknown ids.
  • src/validator.ts — Broadened isEmail (long TLDs, e.g. .museum) and isUrl (host with port, e.g. http://localhost:3000).

Verification

  • bun test → 60 pass / 0 fail
  • tsc --noEmit clean
  • A review pass caught a residual rounding-overflow bug in formatRelative, fixed before this PR.

Assumptions & scope

  • No test files modified (tests treated as the spec); no dependencies added.
  • Validator regexes broadened only enough to satisfy tested edge cases — kept lightweight rather than fully RFC-exhaustive to stay in scope.

…ests

- calculator: divide now throws on division by zero
- date-utils: fix off-by-one/rounding overflow in formatRelative unit buckets
- string-utils: implement truncate (word-boundary + ...) and fix wordCount for consecutive spaces
- task-manager: implement remove, update, and sortBy (priority/createdAt)
- validator: broaden isEmail (long TLDs) and isUrl (host:port) regexes

All 60 tests pass. No test files or dependencies changed.
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