agentsqripts
Version:
Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems
58 lines (51 loc) • 1.75 kB
JavaScript
/**
* @file Unit tests for messages module
* @description Tests messages configuration module
*/
// 🔗 Tests: messages → DEFAULT_ERROR_MESSAGE → ERROR_CONTEXT_FORMATSTRING → TEST_SUCCESS_MESSAGE
// Use qtests setup for consistent testing environment
const { testHelpers, createAssertions } = require('qtests');
const mod = require('./messages.js');
/**
* qtests test suite for messages
*/
function getTestSuite() {
const assert = createAssertions();
return {
'Messages module loads correctly': async () => {
await testHelpers.withSavedEnv(async () => {
// Verify main configurations are exported
assert.truthy(mod.DEFAULT_ERROR_MESSAGE !== undefined, 'DEFAULT_ERROR_MESSAGE should be exported');
assert.truthy(mod.ERROR_CONTEXT_FORMATSTRING !== undefined, 'ERROR_CONTEXT_FORMATSTRING should be exported');
assert.truthy(mod.TEST_SUCCESS_MESSAGE !== undefined, 'TEST_SUCCESS_MESSAGE should be exported');
});
}
};
}
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);
}
})();
}