Conversation
…ests - calculator.divide: throw on division by zero - string-utils.wordCount: collapse consecutive whitespace - string-utils.truncate: implement word-boundary truncation with ellipsis - task-manager: implement remove, update, and sortBy - date-utils: round diffDays instead of floor (36h -> 2 days) - validator: accept long TLDs (isEmail) and ports (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 across 5 files. Test suite now: 60 pass / 0 fail,
tsc --noEmitclean. No test files modified, no dependencies added.Changes by file
src/calculator.ts—dividethrowsError("Division by zero")when divisor is0(was silently returningInfinity/NaN).src/string-utils.tswordCount— trims and splits on/\s+/so runs of whitespace no longer count as extra words.truncate— implemented per the TODO spec: returns unchanged ifstr.length <= maxLength; otherwise reserves 3 chars for"...", cuts to budget, and backs up to the last word boundary. Falls back to a hard cut when the first word exceeds the budget.src/task-manager.ts— implemented stubbed methods:remove(returns delete boolean),update(returns false for unknown id; applies only provided keys),sortBy(priority high→medium→low;createdAtoldest first).src/date-utils.ts—diffDaysusesMath.roundinstead ofMath.floor, so 36h now reads "2 days ago".src/validator.ts—isEmailaccepts long TLDs ({2,});isUrlaccepts URLs with a port.Assumptions & notes
dividethrowing is a behavioural change for any caller that relied onInfinity— driven by the test.isUrlnow accepting arbitrary ports widens accepted input; if it ever guards outbound requests, port-restriction may be worth revisiting (SSRF surface). Out of scope for these tests.createdAtsort relies on spec-stableArray.prototype.sortso same-ms ties keep insertion order.Testing
bun test— 60 pass / 0 failtsc --noEmit— clean