cli.test.tsā¢1.85 kB
import { exec } from 'child_process';
import { promisify } from 'util';
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const execAsync = promisify(exec);
describe('CLI', () => {
const cliPath = path.join(__dirname, '../../dist/cli.js');
describe('Help and Version', () => {
test('should display help when --help flag is provided', async () => {
// This test will fail until CLI is implemented
try {
const { stdout } = await execAsync(`node ${cliPath} --help`);
expect(stdout).toContain('cut-copy-paste-mcp');
expect(stdout).toContain('Usage:');
} catch (error) {
// Expected to fail in RED phase
expect(error).toBeDefined();
}
}, 10000);
test('should display version when --version flag is provided', async () => {
// This test will fail until CLI is implemented
try {
const { stdout } = await execAsync(`node ${cliPath} --version`);
expect(stdout).toContain('1.0.0');
} catch (error) {
// Expected to fail in RED phase
expect(error).toBeDefined();
}
}, 10000);
});
describe('Server Startup', () => {
test('CLI file should exist after build', () => {
// This will fail until we build
const exists = fs.existsSync(cliPath);
expect(exists).toBe(true);
});
test('CLI file should have executable shebang', () => {
// This will fail until CLI is created
if (fs.existsSync(cliPath)) {
const content = fs.readFileSync(cliPath, 'utf-8');
expect(content.startsWith('#!/usr/bin/env node')).toBe(true);
} else {
expect(fs.existsSync(cliPath)).toBe(true);
}
});
});
});