Skip to content

fix: implement missing utilities and fix edge-case test failures - #322

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2185-1788711429
Open

fix: implement missing utilities and fix edge-case test failures#322
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2185-1788711429

Conversation

@stooit

@stooit stooit commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the utility library. bun test now reports 60 pass / 0 fail, and tsc --noEmit is clean. No test files were modified and no dependencies were added.

Changes

  • calculator.divide — throws on division by zero (including -0 and 0/0).
  • string-utils.wordCount — no longer over-counts on multiple consecutive spaces.
  • string-utils.truncate — implemented per the TODO: truncates at a word boundary, with "..." counting toward maxLength; returns the string unchanged when str.length <= maxLength; degrades to a hard cut when maxLength <= 3. Length invariant verified by fuzzing.
  • task-manager (TaskManager) — implemented remove (returns false for unknown id), update (partial updates, returns false for unknown id, only touches keys explicitly present), and sortBy for priority (high > medium > low) and createdAt (oldest first, returns a copy).
  • date-utils.formatRelative — fixed off-by-one at the 36h boundary (now "2 days ago").
  • validator.isEmail / isUrl — accept valid long TLDs and URLs with a port; protocol allowlist retained (javascript:/data:/file: still reject).

Verification

  • bun test -> 60 pass / 0 fail
  • bunx tsc --noEmit -> clean

Assumptions

  • Behaviour was derived directly from the test assertions; only what the tests require was changed.

Follow-ups (out of scope, non-blocking — flagged by review)

  • isEmail local part still uses [^\s@]+, accepting control chars / injection-adjacent payloads (pre-existing).
  • isUrl accepts embedded credentials (https://example.com@evil.com/); consider rejecting username/password if used to gate redirects/fetches.
  • README.md still advertises the now-fixed defects.

- calculator.divide: throw on division by zero (incl. -0 and 0/0)
- string-utils.wordCount: stop over-counting consecutive spaces
- string-utils.truncate: implement word-boundary truncation with ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy (priority + createdAt)
- date-utils.formatRelative: fix off-by-one at the 36h boundary
- validator.isEmail/isUrl: accept valid long TLDs and URLs with ports

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