* refactor(query): deepen command definition seam and fold fallback mapping cleanup * refactor(query): add shared dispatch formatting module seam * fix(query): restore QueryResult type import in dispatch deps * test/query: align raw-output policy and definition normalization contracts * refactor(query): deepen diagnosis, invariant report, and error taxonomy seams * refactor(query): deepen dispatch plan, fallback bridge, policy snapshot, and hints seams * refactor(query): deepen validation, fallback policy, capability, and result builder seams * refactor(query): deepen resolution strategy, output classifier, observability, and policy-capability seams * refactor(query): finalize deep strategy/classifier/observability/capability seams * test/query: address coderabbit inline and out-of-diff dispatch nits * fix(query): address remaining coderabbit input-validation and bridge stderr threads * fix(query): address remaining coderabbit dispatch and strategy/output nits
29 lines
809 B
TypeScript
29 lines
809 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { formatPick, formatSuccess } from './query-dispatch-formatting.js';
|
|
|
|
describe('query-dispatch-formatting', () => {
|
|
it('formats text with trailing newline', () => {
|
|
expect(formatSuccess('USAGE', 'text')).toBe('USAGE\n');
|
|
});
|
|
|
|
it('formats json with pretty printing', () => {
|
|
expect(formatSuccess({ nested: { value: 3 } }, 'json')).toBe([
|
|
'{',
|
|
' "nested": {',
|
|
' "value": 3',
|
|
' }',
|
|
'}',
|
|
'',
|
|
].join('\n'));
|
|
});
|
|
|
|
it('formats json and applies pick', () => {
|
|
expect(formatSuccess({ nested: { value: 3 } }, 'json', 'nested.value')).toBe('3\n');
|
|
});
|
|
|
|
it('formatPick returns input when no pickField', () => {
|
|
const input = { ok: true };
|
|
expect(formatPick(input)).toBe(input);
|
|
});
|
|
});
|