mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-24 21:35:24 +02:00
Some checks are pending
CI: Master (Build, Test, Lint) / Build for Github Cache (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (22.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (24.13.1) (push) Waiting to run
CI: Master (Build, Test, Lint) / Unit tests (25.x) (push) Waiting to run
CI: Master (Build, Test, Lint) / Lint (push) Waiting to run
CI: Master (Build, Test, Lint) / Performance (push) Waiting to run
CI: Master (Build, Test, Lint) / Notify Slack on failure (push) Blocked by required conditions
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import * as Helpers from './helpers';
|
|
import type { NodeParameterValueType } from '../src';
|
|
import { Workflow } from '../src/workflow';
|
|
|
|
describe('WorkflowExpression', () => {
|
|
describe('getParameterValue()', () => {
|
|
const nodeTypes = Helpers.NodeTypes();
|
|
const workflow = new Workflow({
|
|
id: '1',
|
|
nodes: [
|
|
{
|
|
name: 'node',
|
|
typeVersion: 1,
|
|
type: 'test.set',
|
|
id: 'uuid-1234',
|
|
position: [0, 0],
|
|
parameters: {},
|
|
},
|
|
],
|
|
connections: {},
|
|
active: false,
|
|
nodeTypes,
|
|
});
|
|
const expression = workflow.expression;
|
|
|
|
beforeAll(async () => {
|
|
await expression.acquireIsolate();
|
|
});
|
|
afterAll(async () => {
|
|
await expression.releaseIsolate();
|
|
});
|
|
|
|
const evaluate = (value: NodeParameterValueType) =>
|
|
expression.getParameterValue(value, null, 0, 0, 'node', [], 'manual', {});
|
|
|
|
it('should resolve $parameter["&key"] sibling reference within an object', () => {
|
|
// n8n uses the `&`-prefixed syntax internally (e.g. in node parameter definitions)
|
|
// to reference sibling fields: `={{ $parameter["&key"].split("|")[1] }}`
|
|
// getParameterValue must pass the parent object as siblingParameters so these resolve.
|
|
const result = evaluate({
|
|
key: 'title|display',
|
|
type: '={{$parameter["&key"].split("|")[1]}}',
|
|
});
|
|
|
|
expect(result).toEqual({ key: 'title|display', type: 'display' });
|
|
});
|
|
});
|
|
});
|