HuggingClaw-MissionControl / src /lib /__tests__ /openclaw-gateway.test.ts
nyk
feat(refactor): ready for manual QA after main sync (#274)
b6ecafa unverified
Raw
History Blame Contribute Delete
622 Bytes
import { describe, expect, it } from 'vitest'
import { parseGatewayJsonOutput } from '@/lib/openclaw-gateway'
describe('parseGatewayJsonOutput', () => {
it('parses embedded object payloads', () => {
expect(parseGatewayJsonOutput('warn\n{"status":"started","runId":"abc"}\n')).toEqual({
status: 'started',
runId: 'abc',
})
})
it('parses embedded array payloads', () => {
expect(parseGatewayJsonOutput('note\n[{"id":1},{"id":2}]')).toEqual([{ id: 1 }, { id: 2 }])
})
it('returns null for non-json output', () => {
expect(parseGatewayJsonOutput('plain text only')).toBeNull()
})
})