/**
 * Copyright Super iPaaS Integration LLC, an IBM Company 2024
 */

import { spawnSync } from 'node:child_process';
import {BUILD_DESC,TEST_DESC,DEPLOY_DESC} from '../../../src/constants/command-constants.js';
describe('Functional tests for the help command', () => {

	test('should display basic help information', () => {
		const result = spawnSync('node', ['dist/cli.js', '--help'], { encoding: 'utf-8' });
		expect(result.stdout).toContain('Usage: wm [options] [command]');
		expect(result.stdout).toContain('Commands:');
	});

	test('should display basic help information with -h', () => {
		const result = spawnSync('node', ['dist/cli.js', '-h'], { encoding: 'utf-8' });
		expect(result.stdout).toContain('Usage: wm [options] [command]');
		expect(result.stdout).toContain('Commands:');
	});

	test('should display help for build command', () => {
		const result = spawnSync('node', ['dist/cli.js', 'apim', 'help', 'build'], { encoding: 'utf-8' });
		expect(result.stdout).toContain('Usage: wm apim build [options] [projects]');
		expect(result.stdout).toContain(BUILD_DESC);
	});

	test('should display help for deploy command', () => {
		const result = spawnSync('node', ['dist/cli.js', 'apim', 'help', 'deploy'], { encoding: 'utf-8' });
		expect(result.stdout).toContain('Usage: wm apim deploy [options] [projects]');
		expect(result.stdout).toContain(DEPLOY_DESC);
	});

	test('should display help for test command', () => {
		const result = spawnSync('node', ['dist/cli.js', 'apim', 'help', 'test'], { encoding: 'utf-8' });
		expect(result.stdout).toContain('Usage: wm apim test [options] [projects]');
		expect(result.stdout).toContain(TEST_DESC);
	});
});
