MCPcopy
hub / github.com/affaan-m/ECC / runTests

Function runTests

tests/lib/project-detect.test.js:57–478  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57function runTests() {
58 console.log('\n=== Testing project-detect.js ===\n');
59
60 let passed = 0;
61 let failed = 0;
62
63 // Rule definitions tests
64 console.log('Rule Definitions:');
65
66 if (test('LANGUAGE_RULES is non-empty array', () => {
67 assert.ok(Array.isArray(LANGUAGE_RULES));
68 assert.ok(LANGUAGE_RULES.length > 0);
69 })) passed++; else failed++;
70
71 if (test('FRAMEWORK_RULES is non-empty array', () => {
72 assert.ok(Array.isArray(FRAMEWORK_RULES));
73 assert.ok(FRAMEWORK_RULES.length > 0);
74 })) passed++; else failed++;
75
76 if (test('each language rule has type, markers, and extensions', () => {
77 for (const rule of LANGUAGE_RULES) {
78 assert.ok(typeof rule.type === 'string', `Missing type`);
79 assert.ok(Array.isArray(rule.markers), `Missing markers for ${rule.type}`);
80 assert.ok(Array.isArray(rule.extensions), `Missing extensions for ${rule.type}`);
81 }
82 })) passed++; else failed++;
83
84 if (test('each framework rule has framework, language, markers, packageKeys', () => {
85 for (const rule of FRAMEWORK_RULES) {
86 assert.ok(typeof rule.framework === 'string', `Missing framework`);
87 assert.ok(typeof rule.language === 'string', `Missing language for ${rule.framework}`);
88 assert.ok(Array.isArray(rule.markers), `Missing markers for ${rule.framework}`);
89 assert.ok(Array.isArray(rule.packageKeys), `Missing packageKeys for ${rule.framework}`);
90 }
91 })) passed++; else failed++;
92
93 // Empty directory detection
94 console.log('\nEmpty Directory:');
95
96 if (test('empty directory returns unknown primary', () => {
97 const dir = createTempDir();
98 try {
99 const result = detectProjectType(dir);
100 assert.strictEqual(result.primary, 'unknown');
101 assert.deepStrictEqual(result.languages, []);
102 assert.deepStrictEqual(result.frameworks, []);
103 assert.strictEqual(result.projectDir, dir);
104 } finally {
105 cleanupDir(dir);
106 }
107 })) passed++; else failed++;
108
109 // Python detection
110 console.log('\nPython Detection:');
111
112 if (test('detects python from requirements.txt', () => {
113 const dir = createTempDir();
114 try {

Callers 1

Calls 12

detectProjectTypeFunction · 0.85
writeTestFileFunction · 0.85
getPackageJsonDepsFunction · 0.85
getPythonDepsFunction · 0.85
getGoDepsFunction · 0.85
getRustDepsFunction · 0.85
getComposerDepsFunction · 0.85
getElixirDepsFunction · 0.85
okMethod · 0.80
testFunction · 0.70
createTempDirFunction · 0.70
cleanupDirFunction · 0.70

Tested by

no test coverage detected