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

@@ -1396,6 +1396,22 @@ function runTests() {
cleanupTestDir(testDir);
})) passed++; else failed++;
// ── Round 92: detectFromPackageJson with empty string packageManager ──
console.log('\nRound 92: detectFromPackageJson (empty string packageManager):');
if (test('detectFromPackageJson returns null for empty string packageManager field', () => {
// package-manager.js line 114: if (pkg.packageManager) — empty string "" is falsy,
// so the if block is skipped entirely. Function returns null without attempting split.
// This is distinct from Round 91's whitespace test (" " is truthy and enters the if).
const testDir = createTestDir();
fs.writeFileSync(
path.join(testDir, 'package.json'),
JSON.stringify({ name: 'test', packageManager: '' }));
const result = pm.detectFromPackageJson(testDir);
assert.strictEqual(result, null, 'Empty string packageManager should return null (falsy)');
cleanupTestDir(testDir);
})) passed++; else failed++;
// Summary
console.log('\n=== Test Results ===');
console.log(`Passed: ${passed}`);