test(graphify): tighten call-sequence assertions per coderabbit review

Adds explicit call-count and ordering assertions to version-check tests:
- Success path: exactly 1 spawnSync (graphify --version only, no python fallback)
- Failure path: graphify --version attempted first, python3 fallback second

Addresses coderabbit nitpick on PR #2739.
This commit is contained in:
Tom Boucher
2026-04-26 11:21:54 -04:00
parent f89a56eb55
commit 7c08a155ea

View File

@@ -392,9 +392,9 @@ describe('checkGraphifyVersion', () => {
}); });
checkGraphifyVersion(); checkGraphifyVersion();
assert.ok(calls.length >= 1, 'at least one spawnSync call'); assert.strictEqual(calls.length, 1, 'exactly one spawnSync call — no python3 fallback');
assert.strictEqual(calls[0].cmd, 'graphify'); assert.strictEqual(calls[0].cmd, 'graphify');
assert.deepStrictEqual(calls[0].args, ['--version']); assert.ok(calls[0].args.includes('--version'), 'graphify called with --version');
}); });
test('falls back to python3 importlib.metadata when graphify --version fails', () => { test('falls back to python3 importlib.metadata when graphify --version fails', () => {
@@ -411,9 +411,11 @@ describe('checkGraphifyVersion', () => {
const result = checkGraphifyVersion(); const result = checkGraphifyVersion();
assert.strictEqual(result.version, '0.4.3'); assert.strictEqual(result.version, '0.4.3');
assert.strictEqual(result.compatible, true); assert.strictEqual(result.compatible, true);
const pythonCall = calls.find(c => c.cmd === 'python3'); assert.ok(calls.length >= 2, 'at least two spawnSync calls (graphify attempt + python3 fallback)');
assert.ok(pythonCall, 'python3 should be called as fallback'); assert.ok(calls[0].args.includes('--version'), 'graphify --version attempted first');
assert.ok(pythonCall.args.some(arg => arg.includes('importlib.metadata'))); const lastCall = calls[calls.length - 1];
assert.strictEqual(lastCall.cmd, 'python3', 'python3 fallback fires last');
assert.ok(lastCall.args.some(arg => arg.includes('importlib.metadata')));
}); });
}); });