Files
workflow-builder/src/__tests__/utils/variableSubstitution.simple.test.ts
T
Nikhil-Doye 5ff245f7d8 Add Jest configuration and testing utilities for improved test coverage
- Introduced a Jest configuration file to set up the testing environment with jsdom and TypeScript support.
- Added setupTests.ts to mock localStorage and console methods, enhancing test reliability and reducing noise.
- Implemented comprehensive test cases for llmProcessor and copilotService, ensuring robust functionality and error handling.
- Created unit tests for variable substitution utility, validating correct behavior for various scenarios.
- Enhanced database connection manager tests to cover connection handling and credential validation.
- Established a workflow store test suite to validate workflow management and node/edge operations.
2025-10-20 15:36:35 -04:00

42 lines
1.2 KiB
TypeScript

import { substituteVariables, NodeOutput } from '../../utils/variableSubstitution';
describe('Variable Substitution - Simple Tests', () => {
it('should substitute basic variables', () => {
const template = 'Hello {{node1.output}}';
const nodeOutputs = new Map<string, NodeOutput>([
['node1', { nodeId: 'node1', output: 'World', data: 'World' }],
]);
const result = substituteVariables(template, nodeOutputs);
expect(result).toBe('Hello World');
});
it('should handle missing nodes gracefully', () => {
const template = 'Hello {{missingNode.output}}';
const nodeOutputs = new Map<string, NodeOutput>();
const result = substituteVariables(template, nodeOutputs);
expect(result).toBe('Hello {{missingNode.output}}');
});
it('should handle empty template', () => {
const template = '';
const nodeOutputs = new Map<string, NodeOutput>();
const result = substituteVariables(template, nodeOutputs);
expect(result).toBe('');
});
it('should handle null template', () => {
const template = null as any;
const nodeOutputs = new Map<string, NodeOutput>();
const result = substituteVariables(template, nodeOutputs);
expect(result).toBe(null);
});
});