test: address remaining coderabbit findings and notes

This commit is contained in:
Tom Boucher
2026-05-03 18:50:35 -04:00
parent ac883f8150
commit 1037b82a98
2 changed files with 21 additions and 4 deletions

View File

@@ -17,8 +17,8 @@ describe('QueryNativeHotpathAdapter', () => {
await expect(adapter.dispatch('state', ['load'], 'state.load', [], 'json')).resolves.toEqual({ ok: true });
await expect(adapter.dispatch('commit', ['m'], 'commit', ['m'], 'raw')).resolves.toEqual('ok');
expect((native as { dispatchJson: ReturnType<typeof vi.fn> }).dispatchJson).toHaveBeenCalledTimes(1);
expect((native as { dispatchRaw: ReturnType<typeof vi.fn> }).dispatchRaw).toHaveBeenCalledTimes(1);
expect((native as { dispatchJson: ReturnType<typeof vi.fn> }).dispatchJson).toHaveBeenCalledWith('state', ['load'], 'state.load', []);
expect((native as { dispatchRaw: ReturnType<typeof vi.fn> }).dispatchRaw).toHaveBeenCalledWith('commit', ['m'], 'commit', ['m']);
});
it('uses fallback when native query disabled', async () => {
@@ -37,7 +37,7 @@ describe('QueryNativeHotpathAdapter', () => {
await expect(adapter.dispatch('state', ['load'], 'state.load', [], 'json')).resolves.toEqual({ from: 'fallback-json' });
await expect(adapter.dispatch('commit', ['m'], 'commit', ['m'], 'raw')).resolves.toEqual('fallback-raw');
expect(execJsonFallback).toHaveBeenCalledTimes(1);
expect(execRawFallback).toHaveBeenCalledTimes(1);
expect(execJsonFallback).toHaveBeenCalledWith('state', ['load']);
expect(execRawFallback).toHaveBeenCalledWith('commit', ['m']);
});
});

View File

@@ -6,6 +6,18 @@ describe('formatQueryRawOutput', () => {
expect(formatQueryRawOutput('commit', { committed: true, hash: 'abc123' })).toBe('abc123');
});
it('returns committed when hash missing', () => {
expect(formatQueryRawOutput('commit', { committed: true })).toBe('committed');
});
it('formats skipped commit reason', () => {
expect(formatQueryRawOutput('commit', { committed: false, reason: 'skipped' })).toBe('skipped');
});
it('formats nothing-to-commit reason', () => {
expect(formatQueryRawOutput('commit', { committed: false, reason: 'nothing_to_commit' })).toBe('nothing');
});
it('formats config-set key=value', () => {
expect(formatQueryRawOutput('config-set', { updated: true, key: 'mode', value: 'yolo' })).toBe('mode=yolo');
});
@@ -14,4 +26,9 @@ describe('formatQueryRawOutput', () => {
expect(formatQueryRawOutput('state.begin-phase', { updated: ['x'] })).toBe('true');
expect(formatQueryRawOutput('state.begin-phase', { updated: [] })).toBe('false');
});
it('formats state begin-phase alias', () => {
expect(formatQueryRawOutput('state begin-phase', { updated: ['x'] })).toBe('true');
expect(formatQueryRawOutput('state begin-phase', { updated: [] })).toBe('false');
});
});