mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
The reusable base the Capabilities rework sits on:
- lib/{text,time,format,json-format}: consolidate ~30 hand-rolled string/date/
number/JSON helpers behind one set of tested utilities.
- master-detail scaffold (MasterDetail / ListColumn / DetailColumn / DetailPane /
CapRow / ListStrip / ToolChip / ICON_BUTTON) + row-hover; tabs-as-data
PageSearchShell; EmptyState + ErrorBanner; a shared LogTail terminal surface.
- framed CodeEditor + JsonDocumentEditor, wired into every in-app markdown/JSON
edit surface (profile SOUL.md, memory nodes, right-click sidebar profile).
- shared React Query cache helper (writeCache) + per-profile-switch/ debounce hooks.
26 lines
639 B
TypeScript
26 lines
639 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { tryFormatJson } from './json-format'
|
|
|
|
describe('tryFormatJson', () => {
|
|
it('pretty-prints compact JSON', () => {
|
|
expect(tryFormatJson('{"a":1,"b":[2,3]}')).toEqual({
|
|
ok: true,
|
|
text: '{\n "a": 1,\n "b": [\n 2,\n 3\n ]\n}'
|
|
})
|
|
})
|
|
|
|
it('leaves empty input unchanged', () => {
|
|
expect(tryFormatJson(' ')).toEqual({ ok: true, text: ' ' })
|
|
})
|
|
|
|
it('reports parse errors', () => {
|
|
const result = tryFormatJson('{bad')
|
|
|
|
expect(result.ok).toBe(false)
|
|
|
|
if (!result.ok) {
|
|
expect(result.error.length).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
})
|