mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
62c096710f
- Fix autofixable violations - Remove unused directives - Allow for PascalCased variables - needed for dynamically imported or assigned classes, decorators, routers, etc.
78 lines
5.9 KiB
TypeScript
78 lines
5.9 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-loop-func */
|
|
import path from 'path';
|
|
import os from 'node:os';
|
|
import type { IDataObject } from 'n8n-workflow';
|
|
import type { WorkflowTestData } from '@test/nodes/types';
|
|
|
|
import {
|
|
getResultNodeData,
|
|
setup,
|
|
initBinaryDataService,
|
|
readJsonFileSync,
|
|
} from '@test/nodes/Helpers';
|
|
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';
|
|
|
|
if (os.platform() !== 'win32') {
|
|
describe('Execute Compression Node', () => {
|
|
beforeEach(async () => {
|
|
await initBinaryDataService();
|
|
});
|
|
|
|
const workflowData = readJsonFileSync('nodes/Compression/test/node/workflow.compression.json');
|
|
|
|
const node = workflowData.nodes.find((n: IDataObject) => n.name === 'Read Binary File');
|
|
node.parameters.filePath = path.join(__dirname, 'lorem.txt');
|
|
|
|
const tests: WorkflowTestData[] = [
|
|
{
|
|
description: 'nodes/Compression/test/node/workflow.compression.json',
|
|
input: {
|
|
workflowData,
|
|
},
|
|
output: {
|
|
nodeData: {
|
|
Compression1: [
|
|
[
|
|
{
|
|
json: {},
|
|
binary: {
|
|
file_0: {
|
|
mimeType: 'text/plain',
|
|
fileType: 'text',
|
|
fileExtension: 'txt',
|
|
data: 'TG9yZW0gSXBzdW0KIk5lcXVlIHBvcnJvIHF1aXNxdWFtIGVzdCBxdWkgZG9sb3JlbSBpcHN1bSBxdWlhIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ciwgYWRpcGlzY2kgdmVsaXQuLi4iCiJUaGVyZSBpcyBubyBvbmUgd2hvIGxvdmVzIHBhaW4gaXRzZWxmLCB3aG8gc2Vla3MgYWZ0ZXIgaXQgYW5kIHdhbnRzIHRvIGhhdm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VsdHJpY2llcyBtYXNzYS4KCk1vcmJpIHNpdCBhbWV0IHJpc3VzIHZlc3RpYnVsdW0sIHZlaGljdWxhIGVsaXQgdmVsLCB1bGxhbWNvcnBlciBhbnRlLiBBZW5lYW4gcnV0cnVtIHBlbGxlbnRlc3F1ZSBmZWxpcywgbmVjIHBoYXJldHJhIGlwc3VtIGNvbnNlY3RldHVyIHF1aXMuIE1hdXJpcyBpbiBlbGl0IGV1IG51bGxhIGRhcGlidXMgZmV1Z2lhdC4gSW4gdmVzdGlidWx1bSBtYXNzYSBpZCBsYW9yZWV0IHNvZGFsZXMuIFN1c3BlbmRpc3NlIG9ybmFyZSBjb25ndWUgbWV0dXMsIGluIHVsdHJpY2llcyBuZXF1ZSBjb25zZXF1YXQgbmVjLiBJbnRlcmR1bSBldCBtYWxlc3VhZGEgZmFtZXMgYWMgYW50ZSBpcHN1bSBwcmltaXMgaW4gZmF1Y2lidXMuIE1hZWNlbmFzIHNlZCBsdWN0dXMgdmVsaXQuIFF1aXNxdWUgaW4gbnVuYyBwZWxsZW50ZXNxdWUsIGFsaXF1ZXQgcXVhbSBpbiwgYWNjdW1zYW4gbGVjdHVzLiBWZXN0aWJ1bHVtIGRhcGlidXMgdG9ydG9yIGFjIG1ldHVzIGZldWdpYXQgY3Vyc3VzLiBTZWQgbmVjIHNjZWxlcmlzcXVlIGFyY3UuCg==',
|
|
fileName: 'lorem.txt',
|
|
fileSize: '3.07 kB',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
const nodeTypes = setup(tests);
|
|
|
|
for (const testData of tests) {
|
|
test(testData.description, async () => {
|
|
const { result } = await executeWorkflow(testData, nodeTypes);
|
|
|
|
const resultNodeData = getResultNodeData(result, testData);
|
|
resultNodeData.forEach(({ nodeName, resultData }) => {
|
|
expect(resultData).toEqual(testData.output.nodeData[nodeName]);
|
|
});
|
|
|
|
expect(result.finished).toEqual(true);
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
describe('Execute Compression Node', () => {
|
|
it('Skipped because compression results are different on platform win32', () => {
|
|
expect(true).toBe(true);
|
|
});
|
|
});
|
|
}
|