test: cover session-end message.role path, getExecCommand non-string args, and legacy hooks format

Round 80: Three previously untested conditional branches:
- session-end.js: entry.message?.role === 'user' third OR condition
  (fires when type is not 'user' but message.role is)
- package-manager.js: getExecCommand with truthy non-string args
  (typeof check short-circuits, value still appended via ternary)
- validate-hooks.js: legacy array format parsing path (lines 115-135)
  with 'Hook N' error labels instead of 'EventType[N]'
This commit is contained in:
Affaan Mustafa
2026-02-13 10:39:35 -08:00
parent 9dccdb9068
commit 2573cbb7b0
3 changed files with 83 additions and 0 deletions

View File

@@ -1331,6 +1331,25 @@ function runTests() {
}
})) passed++; else failed++;
// ── Round 80: getExecCommand with truthy non-string args ──
console.log('\nRound 80: getExecCommand (truthy non-string args):');
if (test('getExecCommand with args=42 (truthy number) appends stringified value', () => {
const originalEnv = process.env.CLAUDE_PACKAGE_MANAGER;
try {
process.env.CLAUDE_PACKAGE_MANAGER = 'npm';
// args=42: truthy, so typeof check at line 334 short-circuits
// (typeof 42 !== 'string'), skipping validation. Line 339:
// 42 ? ' ' + 42 → ' 42' → appended.
const cmd = pm.getExecCommand('prettier', 42);
assert.ok(cmd.includes('prettier'), 'Should include binary name');
assert.ok(cmd.includes('42'), 'Truthy number should be stringified and appended');
} finally {
if (originalEnv !== undefined) process.env.CLAUDE_PACKAGE_MANAGER = originalEnv;
else delete process.env.CLAUDE_PACKAGE_MANAGER;
}
})) passed++; else failed++;
// Summary
console.log('\n=== Test Results ===');
console.log(`Passed: ${passed}`);