agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
68 lines (60 loc) • 2.38 kB
JavaScript
/**
* @file Unit tests for promote-exports CLI
* @description Tests CLI module structure and function exports
*/
// Use qtests setup for consistent testing environment
const { testHelpers, createAssertions } = require('qtests');
const mod = require('./promote-exports.js');
/**
* qtests test suite for promote-exports CLI
*/
function getTestSuite() {
const assert = createAssertions();
return {
'CLI module structure is valid': async () => {
await testHelpers.withSavedEnv(async () => {
// Verify main functions are exported
assert.truthy(typeof mod.main === 'function', 'main function should be exported');
assert.truthy(typeof mod.promoteProjectExports === 'function', 'promoteProjectExports function should be exported');
assert.truthy(typeof mod.promoteExportsInFile === 'function', 'promoteExportsInFile function should be exported');
});
},
'CLI function validation': async () => {
await testHelpers.withSavedEnv(async () => {
// Verify actual exported functions exist
assert.truthy(mod.promoteProjectExports !== undefined, 'promoteProjectExports should be defined');
assert.truthy(mod.promoteExportsInFile !== undefined, 'promoteExportsInFile should be defined');
assert.truthy(mod.updateIndexFile !== undefined, 'updateIndexFile should be defined');
assert.truthy(typeof mod.promoteProjectExports === 'function', 'promoteProjectExports should be a function');
assert.truthy(typeof mod.updateIndexFile === 'function', 'updateIndexFile should be a function');
});
}
};
}
module.exports = { getTestSuite };
// Auto-execute when run directly (for qtests-runner compatibility)
if (require.main === module) {
(async () => {
const testSuite = getTestSuite();
let passed = 0;
let failed = 0;
for (const [testName, testFn] of Object.entries(testSuite)) {
try {
await testFn();
console.log(`✓ ${testName}`);
passed++;
} catch (error) {
console.log(`✗ ${testName}`);
console.error(`Error: ${error.message}`);
failed++;
}
}
if (failed > 0) {
console.log(`\nSummary: ${passed} passed, ${failed} failed`);
process.exit(1);
} else {
console.log(`\nSummary: ${passed} passed`);
process.exit(0);
}
})();
}