UNPKG

agentsqripts

Version:

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

70 lines (62 loc) 2.21 kB
/** * @file Unit tests for performance analysis CLI using qtests * @description Tests CLI argument parsing, help display, and basic structure validation */ // 🔗 Tests: analyze-performance main → analyzePerformance → performanceAnalyzer // Use qtests setup for consistent testing environment const { main } = require('./analyze-performance'); const { stubMethod, testHelpers, createAssertions } = require('qtests'); /** * qtests test suite for performance analysis CLI */ function getTestSuite() { const assert = createAssertions(); return { 'CLI help functionality works correctly': async () => { // Test that help can be displayed without path processing await testHelpers.withSavedEnv(async () => { // Simply test that the function exists and can be called assert.truthy(typeof main === 'function', 'Main function should exist and be callable'); }); }, 'CLI module structure is valid': async () => { // Test that the CLI file has proper structure await testHelpers.withSavedEnv(async () => { // Verify main function export assert.truthy(typeof main === 'function', 'Main function should be exported and callable'); // Verify the module can be required without syntax errors const cliModule = require('./analyze-performance'); assert.truthy(cliModule.main, 'CLI should export main 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); } })(); }