fix: repair all failing utility library tests - #289
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: divide now throws on division by zero instead of returning Infinity - date-utils: correct off-by-one in relative time day rounding - string-utils: implement/repair truncate and wordCount helpers - task-manager: complete missing TaskManager methods (update, remove, sortBy) - validator: isEmail accepts long TLDs; isUrl accepts URLs with ports All 60 tests pass. No test files or dependencies modified.
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 previously-failing tests across the utility library. The full suite is now green: 60 pass / 0 fail. No test files were modified and no dependencies were added.
Changes by file
src/calculator.ts—dividenow throws on division by zero instead of silently returningInfinity. Theb === 0guard also catches-0.src/date-utils.ts— fixed an off-by-one in relative-time day rounding (e.g. 36 hours now reads "2 days ago").src/string-utils.ts— repairedtruncateandwordCount(trim-then-split-on-/\s+/handles consecutive whitespace, tabs, and newlines).src/task-manager.ts— completed missing/incompleteTaskManagermethods (update,remove,sortBy).sortBycopies viaArray.fromso it does not mutate internal state.src/validator.ts—isEmailnow accepts long TLDs (e.g.example.museum) andisUrlaccepts URLs with explicit ports (e.g.http://localhost:3000). The tightened email regex also now rejects empty labels likeuser@example..com.Verification
bun test→ 60 pass / 0 failtsc --noEmitcleansrc/files changed; no test files or dependencies touchedAssumptions & notes
dividewith aNaNdivisor returnsNaNrather than throwing, consistent with the rest of the module and outside the tests' scope.truncatewith a negativemaxLength, andTaskManager.updatebeing unable to clear an optionaldescription.isUrlis a syntax check only, not an SSRF control — the removed port check never provided SSRF protection. Flagged as forward-looking context, not a regression.