refactor(Basic LLM Chain Node): Refactor Basic LLM Chain & add tests (#13850)

This commit is contained in:
oleg
2025-03-14 11:38:22 +01:00
committed by GitHub
parent 311553926a
commit 1bfd128717
24 changed files with 1754 additions and 609 deletions

View File

@@ -0,0 +1,45 @@
import { formatResponse } from '../methods/responseFormatter';
describe('responseFormatter', () => {
describe('formatResponse', () => {
it('should format string responses', () => {
const result = formatResponse('Test response');
expect(result).toEqual({
response: {
text: 'Test response',
},
});
});
it('should trim string responses', () => {
const result = formatResponse(' Test response with whitespace ');
expect(result).toEqual({
response: {
text: 'Test response with whitespace',
},
});
});
it('should handle array responses', () => {
const testArray = [{ item: 1 }, { item: 2 }];
const result = formatResponse(testArray);
expect(result).toEqual({ data: testArray });
});
it('should handle object responses', () => {
const testObject = { key: 'value', nested: { key: 'value' } };
const result = formatResponse(testObject);
expect(result).toEqual(testObject);
});
it('should handle primitive non-string responses', () => {
const testNumber = 42;
const result = formatResponse(testNumber);
expect(result).toEqual({
response: {
text: 42,
},
});
});
});
});