n8n/packages/nodes-base/nodes/Telegram/tests/Helpers.ts
Jon 7ad4badd2d
Some checks failed
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Benchmark Docker Image CI / build (push) Has been cancelled
test(Telegram Node): Add some tests for Telegram (no-changelog) (#11043)
2024-12-02 19:02:08 +00:00

38 lines
1,018 B
TypeScript

import { get } from 'lodash';
import type { IDataObject, IExecuteFunctions, IGetNodeParameterOptions, INode } from 'n8n-workflow';
export const telegramNode: INode = {
id: 'b3039263-29ad-4476-9894-51dfcc5a706d',
name: 'Telegram node',
typeVersion: 1.2,
type: 'n8n-nodes-base.telegram',
position: [0, 0],
parameters: {
resource: 'callback',
operation: 'answerQuery',
},
};
export const createMockExecuteFunction = (nodeParameters: IDataObject) => {
const fakeExecuteFunction = {
getInputData() {
return [{ json: {} }];
},
getNodeParameter(
parameterName: string,
_itemIndex: number,
fallbackValue?: IDataObject | undefined,
options?: IGetNodeParameterOptions | undefined,
) {
const parameter = options?.extractValue ? `${parameterName}.value` : parameterName;
return get(nodeParameters, parameter, fallbackValue);
},
getNode() {
return telegramNode;
},
helpers: {},
continueOnFail: () => false,
} as unknown as IExecuteFunctions;
return fakeExecuteFunction;
};