instruqt
Version:
CLI tool for deploying AI agent context documentation across multiple platforms with dual MERN/module support
108 lines (89 loc) • 4.71 kB
JavaScript
/**
* Unit tests for configuration constants (config/localVars.js)
* Tests that configuration values are properly exported and structured
*/
const { runTestSuite, assertEqual, assertTrue, assertFalse } = require('../lib/testHarness');
/**
* Test configuration constants and structure
* Validates that all required configuration is present and properly structured
*/
function runTests() {
console.log('=== Testing Configuration Constants ===');
// Clear require cache to avoid circular dependency issues
delete require.cache[require.resolve('./localVars')];
const config = require('./localVars');
return runTestSuite('Configuration Constants Tests', {
'exports RULE_DIRS array': () => {
assertTrue(Array.isArray(config.RULE_DIRS), 'RULE_DIRS should be an array');
assertTrue(config.RULE_DIRS.length > 0, 'RULE_DIRS should not be empty');
},
'RULE_DIRS contains expected directories': () => {
const expectedDirs = ['.roo/rules', '.kilocode/rules', '.clinerules'];
expectedDirs.forEach(dir => {
assertTrue(config.RULE_DIRS.includes(dir), `RULE_DIRS should contain ${dir}`);
});
},
'RULE_DIRS contains exactly 3 directories': () => {
assertEqual(config.RULE_DIRS.length, 3, 'RULE_DIRS should contain exactly 3 directories');
},
'exports CONTEXT_MODES object': () => {
assertTrue(typeof config.CONTEXT_MODES === 'object', 'CONTEXT_MODES should be an object');
assertTrue(config.CONTEXT_MODES !== null, 'CONTEXT_MODES should not be null');
},
'CONTEXT_MODES contains npm mapping': () => {
assertTrue('npm' in config.CONTEXT_MODES, 'CONTEXT_MODES should have npm key');
assertEqual(config.CONTEXT_MODES.npm, 'contexts/npm', 'npm should map to contexts/npm');
},
'CONTEXT_MODES contains mern mapping': () => {
assertTrue('mern' in config.CONTEXT_MODES, 'CONTEXT_MODES should have mern key');
assertEqual(config.CONTEXT_MODES.mern, 'contexts/mern', 'mern should map to contexts/mern');
},
'CONTEXT_MODES contains fastapi mapping': () => {
assertTrue('fastapi' in config.CONTEXT_MODES, 'CONTEXT_MODES should have fastapi key');
assertEqual(config.CONTEXT_MODES.fastapi, 'contexts/fastapi', 'fastapi should map to contexts/fastapi');
},
'CONTEXT_MODES contains exactly 3 modes': () => {
const keys = Object.keys(config.CONTEXT_MODES);
assertEqual(keys.length, 3, 'CONTEXT_MODES should contain exactly 3 modes');
},
'CONTEXT_MODES values are strings': () => {
Object.values(config.CONTEXT_MODES).forEach(value => {
assertTrue(typeof value === 'string', 'All CONTEXT_MODES values should be strings');
assertTrue(value.length > 0, 'All CONTEXT_MODES values should be non-empty strings');
});
},
'RULE_DIRS entries are strings': () => {
config.RULE_DIRS.forEach(dir => {
assertTrue(typeof dir === 'string', 'All RULE_DIRS entries should be strings');
assertTrue(dir.length > 0, 'All RULE_DIRS entries should be non-empty strings');
});
},
'RULE_DIRS entries use proper path format': () => {
config.RULE_DIRS.forEach(dir => {
// Most entries should have path separators, but .clinerules is a special case
if (dir !== '.clinerules') {
assertTrue(dir.includes('/'), `RULE_DIRS entry ${dir} should contain path separators`);
}
assertFalse(dir.startsWith('/'), 'RULE_DIRS entries should be relative paths');
});
},
'TEST_FILES array is properly structured': () => {
assertTrue(Array.isArray(config.TEST_FILES), 'TEST_FILES should be an array');
assertTrue(config.TEST_FILES.length > 0, 'TEST_FILES should not be empty');
config.TEST_FILES.forEach(testFile => {
assertTrue(typeof testFile === 'object', 'Each TEST_FILES entry should be an object');
assertTrue(typeof testFile.name === 'string', 'Each test file should have a name');
assertTrue(typeof testFile.path === 'string', 'Each test file should have a path');
});
},
'INTEGRATION_TEST_FILES array is properly structured': () => {
assertTrue(Array.isArray(config.INTEGRATION_TEST_FILES), 'INTEGRATION_TEST_FILES should be an array');
config.INTEGRATION_TEST_FILES.forEach(testFile => {
assertTrue(typeof testFile === 'object', 'Each INTEGRATION_TEST_FILES entry should be an object');
assertTrue(typeof testFile.name === 'string', 'Each integration test file should have a name');
assertTrue(typeof testFile.path === 'string', 'Each integration test file should have a path');
});
}
});
}
module.exports = { runTests };