Skip to content

fix: repair failing tests and implement missing utility functions - #320

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2192-1788452382
Open

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

Conversation

@stooit

@stooit stooit commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library and implements the missing functionality. All 60 tests now pass; no test files were modified and no dependencies were added.

Changes (source only)

  • src/calculator.tsdivide() now throws on division by zero instead of silently returning Infinity.
  • src/date-utils.tsformatRelative() rounds days to the nearest value (36h → "2 days ago") and is symmetric for future dates by taking Math.abs before rounding.
  • src/validator.tsisEmail() accepts subdomains and long TLDs (e.g. .museum); isUrl() accepts URLs with a port (e.g. http://localhost:3000). Protocol allow-listing (http/https) retained.
  • src/string-utils.tswordCount() collapses consecutive whitespace; implemented truncate() with word-boundary truncation, ellipsis counting toward maxLength, whitespace-aware boundaries, and a non-positive maxLength guard.
  • src/task-manager.ts — implemented remove(), update(), and sortBy() (priority high>medium>low, status workflow order, createdAt oldest-first).

Verification

bun test  →  60 pass / 0 fail
tsc --noEmit  →  clean

Review notes / assumptions

A review pass caught two extra defects in previously-untested branches, both now fixed: formatRelative future-date asymmetry, and truncate splitting mid-word on tabs/newlines / over-length output for negative maxLength.

Assumptions:

  • sortBy("createdAt") relies on Array.prototype.sort stability (ES2019+) for same-millisecond ties.
  • update({ description: undefined }) does not clear the field (partial-update semantics).
  • isUrl is a protocol/format check, not an SSRF control — unchanged from prior behaviour.

- calculator: divide() throws on division by zero instead of returning Infinity
- date-utils: formatRelative() rounds days to nearest and is symmetric for future dates
- validator: isEmail() supports subdomains and long TLDs; isUrl() allows ports
- string-utils: wordCount() collapses consecutive whitespace; implement truncate()
  with whitespace-aware word boundaries and non-positive maxLength guard
- task-manager: implement remove(), update(), and sortBy()

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