mirror of
https://github.com/Nikhil-Doye/workflow-builder.git
synced 2026-07-22 02:01:56 +02:00
5ff245f7d8
- 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.
42 lines
1.2 KiB
TypeScript
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);
|
|
});
|
|
});
|