mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-08 10:23:30 +08:00
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:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user