58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { Command } from 'commander';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { registerForgeCommand } from './cli.js';
|
|
|
|
describe('registerForgeCommand', () => {
|
|
it('registers a "forge" command on the parent program', () => {
|
|
const program = new Command();
|
|
registerForgeCommand(program);
|
|
|
|
const forgeCmd = program.commands.find((c) => c.name() === 'forge');
|
|
expect(forgeCmd).toBeDefined();
|
|
});
|
|
|
|
it('registers the four required subcommands under forge', () => {
|
|
const program = new Command();
|
|
registerForgeCommand(program);
|
|
|
|
const forgeCmd = program.commands.find((c) => c.name() === 'forge');
|
|
expect(forgeCmd).toBeDefined();
|
|
|
|
const subNames = forgeCmd!.commands.map((c) => c.name());
|
|
|
|
expect(subNames).toContain('run');
|
|
expect(subNames).toContain('status');
|
|
expect(subNames).toContain('resume');
|
|
expect(subNames).toContain('personas');
|
|
});
|
|
|
|
it('registers "personas list" as a subcommand of "forge personas"', () => {
|
|
const program = new Command();
|
|
registerForgeCommand(program);
|
|
|
|
const forgeCmd = program.commands.find((c) => c.name() === 'forge');
|
|
const personasCmd = forgeCmd!.commands.find((c) => c.name() === 'personas');
|
|
expect(personasCmd).toBeDefined();
|
|
|
|
const personasSubNames = personasCmd!.commands.map((c) => c.name());
|
|
expect(personasSubNames).toContain('list');
|
|
});
|
|
|
|
it('does not modify the parent program name or description', () => {
|
|
const program = new Command('mosaic');
|
|
program.description('Mosaic Stack CLI');
|
|
registerForgeCommand(program);
|
|
|
|
expect(program.name()).toBe('mosaic');
|
|
expect(program.description()).toBe('Mosaic Stack CLI');
|
|
});
|
|
|
|
it('can be called multiple times without throwing', () => {
|
|
const program = new Command();
|
|
expect(() => {
|
|
registerForgeCommand(program);
|
|
}).not.toThrow();
|
|
});
|
|
});
|