mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Overhaul nodes-testing setup - Part 3 (no-changelog) (#14967)
This commit is contained in:
committed by
GitHub
parent
3e43f9f8bc
commit
979f9e6327
@@ -1,15 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-loop-func */
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import type { WorkflowTestData } from 'n8n-workflow';
|
||||
import path from 'path';
|
||||
|
||||
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
||||
import * as Helpers from '@test/nodes/Helpers';
|
||||
|
||||
describe('Test Read Binary Files Node', () => {
|
||||
const workflow = Helpers.readJsonFileSync(
|
||||
'nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json',
|
||||
);
|
||||
const node = workflow.nodes.find((n: any) => n.name === 'Read Binary Files');
|
||||
const testHarness = new NodeTestHarness();
|
||||
const workflowData = testHarness.readWorkflowJSON('ReadBinaryFiles.workflow.json');
|
||||
const node = workflowData.nodes.find((n) => n.name === 'Read Binary Files')!;
|
||||
const dir = path.join(__dirname, 'data').split('\\').join('/');
|
||||
node.parameters.fileSelector = `${dir}/*.json`;
|
||||
|
||||
@@ -17,9 +13,10 @@ describe('Test Read Binary Files Node', () => {
|
||||
{
|
||||
description: 'nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json',
|
||||
input: {
|
||||
workflowData: workflow,
|
||||
workflowData,
|
||||
},
|
||||
output: {
|
||||
assertBinaryData: true,
|
||||
nodeData: {
|
||||
'Read Binary Files': [
|
||||
[
|
||||
@@ -30,7 +27,6 @@ describe('Test Read Binary Files Node', () => {
|
||||
fileType: 'json',
|
||||
fileExtension: 'json',
|
||||
data: 'ewoJInRpdGxlIjogIkxvcmVtIElwc3VtIgp9Cg==',
|
||||
directory: dir,
|
||||
fileName: 'sample.json',
|
||||
fileSize: '28 B',
|
||||
},
|
||||
@@ -44,7 +40,6 @@ describe('Test Read Binary Files Node', () => {
|
||||
fileType: 'json',
|
||||
fileExtension: 'json',
|
||||
data: 'ewoJInRpdGxlIjogIklwc3VtIExvcmVtIgp9Cg==',
|
||||
directory: dir,
|
||||
fileName: 'sample2.json',
|
||||
fileSize: '28 B',
|
||||
},
|
||||
@@ -59,15 +54,6 @@ describe('Test Read Binary Files Node', () => {
|
||||
];
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => {
|
||||
const { result } = await executeWorkflow(testData);
|
||||
|
||||
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
||||
resultNodeData.forEach(({ nodeName, resultData }) =>
|
||||
expect(resultData).toEqual(testData.output.nodeData[nodeName]),
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
});
|
||||
testHarness.setupTest(testData);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user