test(formatting): characterize byte size formatting helpers#159
Merged
Conversation
Add characterization coverage for formatBytes and formatFileSize in packages/flow/src/core/formatting/bytes.ts, a previously untested pure function. Documents current behavior including unit promotion at 1024 boundaries, trailing-zero trimming, custom decimal rounding, TB clamping for petabyte-scale inputs, and NaN propagation for non-positive inputs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Adds characterization tests for
formatBytesandformatFileSizeinpackages/flow/src/core/formatting/bytes.ts— previously untested pure functions.Why
Pins current behavior so future refactors are safe. Follows the same characterization style as #157 (version helpers) and #158 (object helpers).
Coverage
Bytes) and short (B) unit labels1.50→1.5,2.00→2)decimalswith half-up rounding before trimmingshortUnitslabels for non-zero values5120 TB)"NaN undefined"output)formatFileSizedelegation (1 decimal + short units), incl. the docstring-vs-actual discrepancy where1 MBtrims its trailing zeroAll assertions verified empirically against the live implementation.
Verification
bun test: 13 pass / 0 failtsc --noEmit: clean🤖 Generated with Claude Code