test(directory-layout): move sanitizer tests next to src/readme-html-sanitizer.ts - #983
Merged
Merged
Conversation
scripts/check-readme-sync.test.ts is the only unit test file and it exercised src/readme-html-sanitizer.ts alongside the readme-sync script it is named after. Contributors changing the sanitizer had no tree-visible signal that its test lived under scripts/ instead of next to the module, widening the search when a src/ change needed a matching test. Split the sanitizer test cases into src/readme-html-sanitizer.test.ts, importing directly from src/upstream-readme-source.ts instead of through the scripts/ re-export, and keep scripts/check-readme-sync.test.ts scoped to the readme-sync script. Update test:unit to run both files explicitly.
Code Metrics Report
Details | | main (6219157) | #983 (5cb1eed) | +/- |
|---------------------|----------------|----------------|------|
| Coverage | 91.2% | 91.2% | 0.0% |
| Files | 3 | 3 | 0 |
| Lines | 114 | 114 | 0 |
| Covered | 104 | 104 | 0 |
- | Code to Test Ratio | 1:0.9 | 1:0.3 | -0.6 |
| Code | 306 | 793 | +487 |
| Test | 288 | 288 | 0 |
- | Test Execution Time | 13s | 18s | +5s |Reported by octocov |
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.
Why
scripts/is this repo's home for operational/support scripts, but its only unit test file,scripts/check-readme-sync.test.ts, also directly exercisedsrc/readme-html-sanitizer.ts(the runtime module that sanitizes the rendered README HTML), not just the readme-sync script it is named after.package.json'stest:unitwas pinned to that single file, so the sanitizer's tests had no tree-visible location of their own. A contributor changingsrc/readme-html-sanitizer.tscould not infer from the directory layout where its test lived, widening the search on every sanitizer change.What changed
scripts/check-readme-sync.test.tsinto a newsrc/readme-html-sanitizer.test.ts, co-located with the module they test.sanitizeReadmeHtmlTreefrom./readme-html-sanitizerand the upstream repo constants directly from./upstream-readme-source, instead of going through thescripts/check-readme-sync.tsre-export.scripts/check-readme-sync.test.tsnow only coverscheckReadmeSync(the readme-sync script itself).test:unitinpackage.jsonto run both test files explicitly.No behavior changes: the same 17 test cases still run, unchanged.
Verification
bun test scripts/check-readme-sync.test.ts src/readme-html-sanitizer.test.ts-- 17 pass, 0 fail.biome check .-- passes (only a pre-existing, unrelated config deprecation notice).Finding:
audit-directory-layout-audit-003.