test: add Round 92 tests for object pattern, UNC path, and empty packageManager

- Test countInFile returns 0 for object pattern type (non-string non-RegExp)
- Test getSessionStats treats Windows UNC path as content (not file path)
- Test detectFromPackageJson returns null for empty string packageManager field

Total tests: 836
This commit is contained in:
Affaan Mustafa
2026-02-13 14:05:24 -08:00
parent 14dfe4d110
commit b9a38b2680
3 changed files with 46 additions and 0 deletions

View File

@@ -1231,6 +1231,23 @@ function runTests() {
}
})) passed++; else failed++;
// ── Round 92: countInFile with object pattern type ──
console.log('\nRound 92: countInFile (non-string non-RegExp pattern):');
if (test('countInFile returns 0 for object pattern (neither string nor RegExp)', () => {
// utils.js line 443-444: The else branch returns 0 when pattern is
// not instanceof RegExp and typeof !== 'string'. An object like {invalid: true}
// triggers this early return without throwing.
const testFile = path.join(utils.getTempDir(), `utils-test-obj-pattern-${Date.now()}.txt`);
try {
utils.writeFile(testFile, 'some test content to match against');
const count = utils.countInFile(testFile, { invalid: 'object' });
assert.strictEqual(count, 0, 'Object pattern should return 0');
} finally {
try { fs.unlinkSync(testFile); } catch { /* best-effort */ }
}
})) passed++; else failed++;
// Summary
console.log('\n=== Test Results ===');
console.log(`Passed: ${passed}`);