UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

65 lines (60 loc) 1.96 kB
/** * @file Common test assertions * @description Shared test assertion utilities to reduce duplication in test files */ /** * Assert that a value is an object with expected structure * @param {any} actual - Value to test * @param {string} description - Description of what's being tested */ function assertObjectStructure(actual, description) { if (typeof actual !== 'object' || actual === null) { throw new Error(`${description} is not an object`); } console.log(`✓ ${description} returns valid structure`); } /** * Assert that a value is an array * @param {any} actual - Value to test * @param {string} description - Description of what's being tested */ function assertArray(actual, description) { if (!Array.isArray(actual)) { throw new Error(`${description} is not an array`); } console.log(`✓ ${description} returns valid array`); } /** * Common test result structure assertion * @param {any} result - Result to test * @param {string} testName - Name of the test */ function assertAnalysisResult(result, testName) { if (!result || typeof result !== 'object') { throw new Error(`${testName} did not return a valid object`); } if (!result.summary || typeof result.summary !== 'object') { throw new Error(`${testName} missing summary object`); } console.log(`✓ ${testName} returns valid analysis`); } /** * Assert file analysis result structure * @param {any} result - Result to test * @param {string} testName - Name of the test */ function assertFileAnalysisResult(result, testName) { if (!result || typeof result !== 'object') { throw new Error(`${testName} did not return a valid object`); } if (!Array.isArray(result.issues)) { throw new Error(`${testName} missing issues array`); } console.log(`✓ ${testName} returns valid analysis structure`); } module.exports = { assertObjectStructure, assertArray, assertAnalysisResult, assertFileAnalysisResult };