hivecast-sdk/packages/cli/tests/unit/cli-help.spec.ts

108 lines
4.5 KiB
TypeScript

/**
* Unit tests for Matrix SDK CLI basic functionality.
*/
import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import { createProgram } from '../../src/index.js';
describe('Matrix SDK CLI foundation', () => {
it('creates program with correct name and version', () => {
const program = createProgram();
assert.equal(program.name(), 'matrix');
// Version is set via .version() method
const opts = program.opts();
assert.ok(program.commands.length > 0, 'Should have commands registered');
});
it('has init command', () => {
const program = createProgram();
const initCmd = program.commands.find(cmd => cmd.name() === 'init');
assert.ok(initCmd, 'Should have init command');
assert.equal(initCmd.description(), 'Initialize a new Matrix package');
});
it('has actor command', () => {
const program = createProgram();
const actorCmd = program.commands.find(cmd => cmd.name() === 'actor');
assert.ok(actorCmd, 'Should have actor command');
assert.equal(actorCmd.description(), 'Scaffold a new actor package');
assert.equal(actorCmd.options.some(option => option.long === '--dev'), false);
});
it('has install command', () => {
const program = createProgram();
const installCmd = program.commands.find(cmd => cmd.name() === 'install');
assert.ok(installCmd, 'Should have install command');
});
it('has fork command', () => {
const program = createProgram();
const forkCmd = program.commands.find(cmd => cmd.name() === 'fork');
assert.ok(forkCmd, 'Should have fork command');
});
it('has publish command', () => {
const program = createProgram();
const publishCmd = program.commands.find(cmd => cmd.name() === 'publish');
assert.ok(publishCmd, 'Should have publish command');
});
it('has search command', () => {
const program = createProgram();
const searchCmd = program.commands.find(cmd => cmd.name() === 'search');
assert.ok(searchCmd, 'Should have search command');
});
it('has config command', () => {
const program = createProgram();
const configCmd = program.commands.find(cmd => cmd.name() === 'config');
assert.ok(configCmd, 'Should have config command');
const explainCmd = configCmd.commands.find(cmd => cmd.name() === 'explain');
assert.equal(explainCmd, undefined);
});
it('has list command', () => {
const program = createProgram();
const listCmd = program.commands.find(cmd => cmd.name() === 'list');
assert.ok(listCmd, 'Should have list command');
});
it('does not expose managed host commands', () => {
const program = createProgram();
const serviceCmd = program.commands.find(cmd => cmd.name() === 'service');
const runCmd = program.commands.find(cmd => cmd.name() === 'run');
const upCmd = program.commands.find(cmd => cmd.name() === 'up');
assert.equal(serviceCmd, undefined);
assert.equal(runCmd, undefined);
assert.equal(upCmd, undefined);
});
it('has package run command', () => {
const program = createProgram();
const packageCmd = program.commands.find(cmd => cmd.name() === 'package');
assert.ok(packageCmd, 'Should have package command');
const packageRunCmd = packageCmd.commands.find(cmd => cmd.name() === 'run');
assert.ok(packageRunCmd, 'Should have package run command');
assert.equal(packageRunCmd.description(), 'Run one package directly on the selected Space bus without managed host inventory');
});
it('has local demo broker commands', () => {
const program = createProgram();
const brokerCmd = program.commands.find(cmd => cmd.name() === 'broker');
assert.ok(brokerCmd, 'Should have broker command');
assert.ok(brokerCmd.commands.find(cmd => cmd.name() === 'setup'), 'Should have broker setup command');
assert.ok(brokerCmd.commands.find(cmd => cmd.name() === 'start'), 'Should have broker start command');
assert.ok(brokerCmd.commands.find(cmd => cmd.name() === 'stop'), 'Should have broker stop command');
});
it('does not expose provider machine-link credential commands', () => {
const program = createProgram();
const refreshCmd = program.commands.find(cmd => cmd.name() === 'refresh-credentials');
const revokeCmd = program.commands.find(cmd => cmd.name() === 'revoke-device');
const linkStatusCmd = program.commands.find(cmd => cmd.name() === 'link-status');
assert.equal(refreshCmd, undefined);
assert.equal(revokeCmd, undefined);
assert.equal(linkStatusCmd, undefined);
});
});