tinyagent-ts
Version:
Modern TypeScript framework for building AI agents with pluggable tools and ReAct reasoning
21 lines • 872 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const json_1 = require("../src/utils/json");
describe('extractJson', () => {
const cases = [
{ input: 'prefix {"a":1} suffix', expected: '{"a":1}' },
{ input: 'no json here', expected: null },
{ input: '{"a": {"b":2}} trailing', expected: '{"a": {"b":2}}' },
{ input: '```json\n{"c":3}\n```', expected: '{"c":3}' },
{
input: '```json\n{"a":1}\n```\ntext\n```json\n{"b":2}\n```',
expected: '{"a":1}',
},
{ input: '{} just braces {"x":1}', expected: '{}' },
{ input: '{"a": } {"b":2}', expected: '{"b":2}' },
];
it.each(cases)('extracts JSON from %p', ({ input, expected }) => {
expect((0, json_1.extractJson)(input)).toBe(expected);
});
});
//# sourceMappingURL=json.utils.test.js.map