Skip to content

fix: repair failing utility-library tests (16 → 0 failures) - #333

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2176-1788985730
Open

fix: repair failing utility-library tests (16 → 0 failures)#333
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2176-1788985730

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the TypeScript utility library. Final result: 60 pass / 0 fail, tsc --noEmit clean. No test files modified, no dependencies added.

Changes by file

  • src/calculator.tsdivide now throws on division by zero.
  • src/string-utils.tswordCount collapses consecutive whitespace ("hello world" → 2); implemented truncate (word-boundary cut, "..." counts toward maxLength, returns unchanged when within limit). Added a RangeError guard for non-finite/negative maxLength.
  • src/task-manager.ts — implemented remove and update (return false for unknown id), and sortBy (priority high→medium→low; createdAt oldest-first).
  • src/date-utils.ts — fixed formatRelative off-by-one at the 36-hour boundary.
  • src/validator.tsisEmail now accepts long TLDs and rejects leading/trailing/consecutive dots in the local part; isUrl handles URLs with a port.

Assumptions & notes

  • Expected behaviour was derived directly from the existing test cases (the spec). Test files were left untouched.
  • isEmail was tightened (dot as an explicit separator) beyond the minimal fix; quoted local parts and IP-literal domains remain unsupported by design.
  • isUrl accepts loopback/localhost (required by tests). SSRF caveats for callers documented in the source.
  • TaskManager.update/remove take no actor parameter — authorization is intentionally left to the caller/API layer.

Verification

```
bun test → 60 pass, 0 fail, 70 expect() calls
```

- calculator: divide now throws on division by zero
- string-utils: wordCount collapses consecutive spaces; implement truncate
  with word-boundary + ellipsis-in-limit and maxLength bounds guard
- task-manager: implement remove/update (false for unknown id) and sortBy
  (priority high>medium>low, createdAt oldest-first)
- date-utils: fix formatRelative off-by-one at 36h boundary
- validator: fix isEmail long TLD + tighten local-part dot rules;
  fix isUrl port handling
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