Files
alighasami 3d5eaf9445
Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

64 lines
1.7 KiB
TypeScript

import { mock } from 'jest-mock-extended';
import type { ISupplyDataFunctions } from 'n8n-workflow';
import { getWorkflowInputValues } from '../GenericFunctions';
describe('getWorkflowInputValues', () => {
const supplyDataFunctions = mock<ISupplyDataFunctions>();
it('should correctly map the binary property', () => {
supplyDataFunctions.getInputData.mockReturnValue([
{
json: { key1: 'value1' },
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
},
{
json: { key2: 'value2' },
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
},
]);
supplyDataFunctions.getNodeParameter
.calledWith('workflowInputs.value', 0)
.mockReturnValueOnce({ additionalKey1: 'additionalValue1' });
supplyDataFunctions.getNodeParameter
.calledWith('workflowInputs.value', 1)
.mockReturnValueOnce({ additionalKey2: 'additionalValue2' });
const result = getWorkflowInputValues.call(supplyDataFunctions);
expect(result).toEqual([
{
json: {
key1: 'value1',
additionalKey1: 'additionalValue1',
},
binary: { file1: { data: 'binaryData1', mimeType: 'image/png' } },
index: 0,
pairedItem: { item: 0 },
},
{
json: {
key2: 'value2',
additionalKey2: 'additionalValue2',
},
binary: { file2: { data: 'binaryData2', mimeType: 'image/jpeg' } },
index: 1,
pairedItem: { item: 1 },
},
]);
expect(supplyDataFunctions.getInputData).toHaveBeenCalled();
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
'workflowInputs.value',
0,
{},
);
expect(supplyDataFunctions.getNodeParameter).toHaveBeenCalledWith(
'workflowInputs.value',
1,
{},
);
});
});