mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
30 lines
787 B
TypeScript
30 lines
787 B
TypeScript
import get from 'lodash/get';
|
|
import { constructExecutionMetaData } from 'n8n-core';
|
|
import type { IDataObject, IExecuteFunctions, IGetNodeParameterOptions, INode } from 'n8n-workflow';
|
|
|
|
export const createMockExecuteFunction = <T = IExecuteFunctions>(
|
|
nodeParameters: IDataObject,
|
|
nodeMock: INode,
|
|
continueBool = false,
|
|
) =>
|
|
({
|
|
getNodeParameter(
|
|
parameterName: string,
|
|
_itemIndex: number,
|
|
fallbackValue?: IDataObject,
|
|
options?: IGetNodeParameterOptions,
|
|
) {
|
|
const parameter = options?.extractValue ? `${parameterName}.value` : parameterName;
|
|
return get(nodeParameters, parameter, fallbackValue);
|
|
},
|
|
getNode() {
|
|
return nodeMock;
|
|
},
|
|
continueOnFail() {
|
|
return continueBool;
|
|
},
|
|
helpers: {
|
|
constructExecutionMetaData,
|
|
},
|
|
}) as unknown as T;
|