test(validate-refs): document test helpers with JSDoc

Added JSDoc to the test/assert/leakCount helpers so the new test file
documents its own helpers. No behaviour change — 6/6 still pass.
This commit is contained in:
Zied Jlassi 2026-06-20 15:20:10 +02:00
parent eecb6dd5f8
commit 9c4dde977d
1 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,11 @@ let totalTests = 0;
let passedTests = 0; let passedTests = 0;
const failures = []; const failures = [];
/**
* Run a single named test case, recording the result and printing a status line.
* @param {string} name - Human-readable test description.
* @param {Function} fn - Test body; throw to signal failure.
*/
function test(name, fn) { function test(name, fn) {
totalTests++; totalTests++;
try { try {
@ -34,11 +39,20 @@ function test(name, fn) {
} }
} }
/**
* Throw an Error with `message` when `condition` is falsy.
* @param {boolean} condition - Expression that must hold.
* @param {string} message - Failure message.
*/
function assert(condition, message) { function assert(condition, message) {
if (!condition) throw new Error(message); if (!condition) throw new Error(message);
} }
// Number of leak lines detected in a content string (filePath is only used for labelling). /**
* Count the leak lines detected in a content string.
* @param {string} content - File content to scan (filePath is only used for labelling).
* @returns {number} Number of lines flagged as absolute-path leaks.
*/
function leakCount(content) { function leakCount(content) {
return checkAbsolutePathLeaks('fixture.md', content).length; return checkAbsolutePathLeaks('fixture.md', content).length;
} }