27 lines
994 B
JavaScript
27 lines
994 B
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const { execFileSync, spawnSync } = require('node:child_process');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
const pkg = require('../package.json');
|
|
|
|
const cli = path.join(__dirname, '..', 'src', 'cli.js');
|
|
|
|
test('CLI prints concise help', () => {
|
|
const output = execFileSync(process.execPath, [cli, '--help'], { encoding: 'utf8' });
|
|
assert.match(output, /crypstie create \[file\|-\]/);
|
|
assert.match(output, /crypstie open <url>/);
|
|
});
|
|
|
|
test('CLI prints package version', () => {
|
|
assert.equal(execFileSync(process.execPath, [cli, '--version'], { encoding: 'utf8' }), `${pkg.version}\n`);
|
|
});
|
|
|
|
test('CLI rejects unknown commands without a stack trace', () => {
|
|
const result = spawnSync(process.execPath, [cli, 'oops'], { encoding: 'utf8' });
|
|
assert.equal(result.status, 1);
|
|
assert.match(result.stderr, /^crypstie: Unknown command/);
|
|
assert.equal(result.stderr.includes(' at '), false);
|
|
});
|