test(Telegram Node): Add some tests for Telegram (no-changelog) (#11043)

This commit is contained in:
Jon
2024-12-02 19:02:08 +00:00
committed by GitHub
parent 0a8a57e4ec
commit 7ad4badd2d
7 changed files with 2156 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
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;
};