import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import type { WorkflowTestData } from 'n8n-workflow';
import os from 'node:os';
import path from 'path';

if (os.platform() !== 'win32') {
	describe('Execute Compression Node', () => {
		const testHarness = new NodeTestHarness();
		const workflowData = testHarness.readWorkflowJSON('workflow.compression.json');

		const node = workflowData.nodes.find((n) => 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: {
					assertBinaryData: true,
					nodeData: {
						Compression1: [
							[
								{
									json: {},
									binary: {
										file_0: {
											mimeType: 'text/plain',
											fileType: 'text',
											fileExtension: 'txt',
											data: '[encoded data, 4096 characters]',
											fileName: 'lorem.txt',
											fileSize: '3.07 kB',
										},
									},
								},
							],
						],
					},
				},
			},
		];

		for (const testData of tests) {
			testHarness.setupTest(testData);
		}
	});
} else {
	describe('Execute Compression Node', () => {
		it('Skipped because compression results are different on platform win32', () => {
			expect(true).toBe(true);
		});
	});
}
