mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 13:14:07 -08:00
62c096710f
- Fix autofixable violations - Remove unused directives - Allow for PascalCased variables - needed for dynamically imported or assigned classes, decorators, routers, etc.
79 lines
2 KiB
TypeScript
79 lines
2 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-loop-func */
|
|
import path from 'path';
|
|
import * as Helpers from '@test/nodes/Helpers';
|
|
import type { WorkflowTestData } from '@test/nodes/types';
|
|
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
|
|
|
describe('Test Read Binary Files Node', () => {
|
|
beforeEach(async () => {
|
|
await Helpers.initBinaryDataService();
|
|
});
|
|
|
|
const workflow = Helpers.readJsonFileSync(
|
|
'nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json',
|
|
);
|
|
const node = workflow.nodes.find((n: any) => n.name === 'Read Binary Files');
|
|
const dir = path.join(__dirname, 'data').split('\\').join('/');
|
|
node.parameters.fileSelector = `${dir}/*.json`;
|
|
|
|
const tests: WorkflowTestData[] = [
|
|
{
|
|
description: 'nodes/ReadBinaryFiles/test/ReadBinaryFiles.workflow.json',
|
|
input: {
|
|
workflowData: workflow,
|
|
},
|
|
output: {
|
|
nodeData: {
|
|
'Read Binary Files': [
|
|
[
|
|
{
|
|
binary: {
|
|
data: {
|
|
mimeType: 'application/json',
|
|
fileType: 'json',
|
|
fileExtension: 'json',
|
|
data: 'ewoJInRpdGxlIjogIkxvcmVtIElwc3VtIgp9Cg==',
|
|
directory: dir,
|
|
fileName: 'sample.json',
|
|
fileSize: '28 B',
|
|
},
|
|
},
|
|
json: {},
|
|
},
|
|
{
|
|
binary: {
|
|
data: {
|
|
mimeType: 'application/json',
|
|
fileType: 'json',
|
|
fileExtension: 'json',
|
|
data: 'ewoJInRpdGxlIjogIklwc3VtIExvcmVtIgp9Cg==',
|
|
directory: dir,
|
|
fileName: 'sample2.json',
|
|
fileSize: '28 B',
|
|
},
|
|
},
|
|
json: {},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const nodeTypes = Helpers.setup(tests);
|
|
|
|
for (const testData of tests) {
|
|
test(testData.description, async () => {
|
|
const { result } = await executeWorkflow(testData, nodeTypes);
|
|
|
|
const resultNodeData = Helpers.getResultNodeData(result, testData);
|
|
resultNodeData.forEach(({ nodeName, resultData }) =>
|
|
expect(resultData).toEqual(testData.output.nodeData[nodeName]),
|
|
);
|
|
|
|
expect(result.finished).toEqual(true);
|
|
});
|
|
}
|
|
});
|