mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { ExpressionError } from 'n8n-workflow';
|
|
import { stringifyExpressionResult } from '../expressions';
|
|
|
|
describe('stringifyExpressionResult()', () => {
|
|
it('should return empty string for non-critical errors', () => {
|
|
expect(
|
|
stringifyExpressionResult({
|
|
ok: false,
|
|
error: new ExpressionError('error message', { type: 'no_execution_data' }),
|
|
}),
|
|
).toEqual('');
|
|
});
|
|
|
|
it('should return an error message for critical errors', () => {
|
|
expect(
|
|
stringifyExpressionResult({
|
|
ok: false,
|
|
error: new ExpressionError('error message', { type: 'no_input_connection' }),
|
|
}),
|
|
).toEqual('[ERROR: No input connected]');
|
|
});
|
|
|
|
it('should return empty string when result is null', () => {
|
|
expect(stringifyExpressionResult({ ok: true, result: null })).toEqual('');
|
|
});
|
|
|
|
it('should return NaN when result is NaN', () => {
|
|
expect(stringifyExpressionResult({ ok: true, result: NaN })).toEqual('NaN');
|
|
});
|
|
|
|
it('should return [empty] message when result is empty string', () => {
|
|
expect(stringifyExpressionResult({ ok: true, result: '' })).toEqual('[empty]');
|
|
});
|
|
|
|
it('should return the result when it is a string', () => {
|
|
expect(stringifyExpressionResult({ ok: true, result: 'foo' })).toEqual('foo');
|
|
});
|
|
});
|