Add tests for base64 and component-title utils#848
Conversation
bdraco
left a comment
There was a problem hiding this comment.
You must use the pr template, do not mangle it
|
@esphbot rr |
PR Review — Add tests for base64 and component-title utilsTests are correct and well-targeted; the blocker is the PR body, not the code. The two test files are accurate against their sources.
Checklist
Automated review by Kōan (Claude) |
Cover the two remaining genuinely-untested pure utils:
- arrayBufferToBase64: known vector, empty buffer, full 0-255 byte
range, and round-trips across and on the 0x8000 chunk boundary
(the seam the chunked join exists to get right).
- stripRedundantComponentSuffix: ' Component'/' Configuration' tail
trimming, anchored/case-sensitive matching, and the empty-result
guard (' Component' -> original, not '').
a8a2e79 to
c6c9eef
Compare
Simple rebaseBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
There was a problem hiding this comment.
Pull request overview
This PR adds unit tests for two previously untested pure utility functions (arrayBufferToBase64 and stripRedundantComponentSuffix) to lock in behavior around chunking boundaries and suffix-trimming edge cases.
Changes:
- Add coverage for
arrayBufferToBase64, including empty input, known vectors, full byte-range round-trip, and0x8000chunk seam cases. - Add coverage for
stripRedundantComponentSuffix, including anchored suffix trimming, empty-result guard, and case-sensitivity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/util/component-title.test.ts | Adds unit tests for suffix stripping behavior and edge cases. |
| test/util/base64.test.ts | Adds unit tests for base64 encoding correctness and chunk-boundary round-trips. |
| import { describe, expect, it } from "vitest"; | ||
| import { arrayBufferToBase64 } from "../../src/util/base64.js"; | ||
|
|
||
| /** Encode a JS string's bytes (latin1) and round-trip it back through atob. */ |
What does this implement/fix?
Adds unit tests for the two remaining genuinely-untested pure utils:
arrayBufferToBase64(src/util/base64.ts) andstripRedundantComponentSuffix(src/util/component-title.ts). Both shipbehaviour with non-obvious edges and had zero coverage.
arrayBufferToBase64chunks at0x8000and joins once to stay linear — thechunk seam is exactly the kind of thing a refactor can silently break. Tests
cover a known vector (
foo→Zm9v), the empty buffer, a full 0-255 byteround-trip, and round-trips both across and exactly on the
0x8000boundary.stripRedundantComponentSuffixhas an empty-result guard (" Component"→original, not
"") and is intentionally anchored + case-sensitive. Testscover suffix trimming, the empty-result guard, anchored-at-end matching, and
case sensitivity. The util is purely textual (the core-only policy lives in
the caller), so
"Copy Component"is still trimmed here.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesChecklist
npm run lintpasses.npm run testpasses.