fix: repair 16 failing tests across utility library#240
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: divide now throws on division by zero - string-utils: wordCount splits on whitespace runs; implement truncate - task-manager: implement remove, update, and sortBy - date-utils: fix off-by-one in formatRelative day rounding - validator: allow long TLDs in isEmail and ports in isUrl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 failing tests in the TypeScript utility library. 60/60 tests now pass with no regressions. Only source files were changed — no test files touched, no dependencies added.
Changes
src/calculator.tsdividethrowsError("Division by zero")when divisor is0src/string-utils.tswordCountsplits on/\s+/(handles consecutive spaces); implementedtruncate(unchanged if within limit, word-boundary truncation, ellipsis counts towardmaxLength, handles strings shorter than the ellipsis)src/task-manager.tsremove(returns bool),update(title/priority, returns bool), andsortBy(priorityhigh→medium→low,createdAtoldest first)src/date-utils.tsformatRelativeday roundingsrc/validator.tsisEmailaccepts long TLDs (e.g..museum);isUrlaccepts URLs with a portAlso removed three stale
BUG:JSDoc comments that described now-fixed behaviour.Verification
bun test→ 60 pass, 0 failAssumptions