import { test } from 'node:test';
import assert from 'node:assert';
import { execFile } from 'child_process';
import { promisify } from 'util';
import path from 'path';
import { fileURLToPath } from 'url';
const execFileAsync = promisify(execFile);
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const cliPath = path.join(__dirname, '..', 'cli.js');
test('CLI shows help', async () => {
const { stdout } = await execFileAsync('node', [cliPath, '--help']);
assert(stdout.includes('proofmode <command> [options]'));
assert(stdout.includes('check'));
assert(stdout.includes('generate'));
assert(stdout.includes('sign'));
});
test('CLI shows version', async () => {
const { stdout } = await execFileAsync('node', [cliPath, '--version']);
assert(stdout.includes('0.4.0'));
});
test('CLI requires command', async () => {
try {
await execFileAsync('node', [cliPath]);
assert.fail('Should have thrown error');
} catch (error) {
assert(error.stderr.includes('You must specify a command'));
}
});
test('Check command requires input', async () => {
try {
await execFileAsync('node', [cliPath, 'check']);
assert.fail('Should have thrown error');
} catch (error) {
assert(error.stderr.includes('At least one of --file, --dir, --url, or --cid must be specified'));
}
});
test('Generate command requires input', async () => {
try {
await execFileAsync('node', [cliPath, 'generate']);
assert.fail('Should have thrown error');
} catch (error) {
assert(error.stderr.includes('At least one of --file or --dir must be specified'));
}
});