81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { generateBashCompletion, generateZshCompletion, generateFishCompletion } from './completion.js';
|
|
|
|
const EXPECTED_SUBCOMMANDS = ['start', 'tui', 'send', 'sessions', 'doctor', 'config', 'completion'];
|
|
|
|
describe('generateBashCompletion', () => {
|
|
it('generates valid bash completion', () => {
|
|
const script = generateBashCompletion();
|
|
expect(script).toContain('_flynn_completions');
|
|
expect(script).toContain('complete -F _flynn_completions flynn');
|
|
});
|
|
|
|
it('contains all subcommands', () => {
|
|
const script = generateBashCompletion();
|
|
for (const cmd of EXPECTED_SUBCOMMANDS) {
|
|
expect(script).toContain(cmd);
|
|
}
|
|
});
|
|
|
|
it('contains global options', () => {
|
|
const script = generateBashCompletion();
|
|
expect(script).toContain('--help');
|
|
expect(script).toContain('--version');
|
|
});
|
|
|
|
it('contains subcommand-specific options', () => {
|
|
const script = generateBashCompletion();
|
|
expect(script).toContain('--config');
|
|
expect(script).toContain('--fullscreen');
|
|
expect(script).toContain('--no-tools');
|
|
expect(script).toContain('--raw');
|
|
});
|
|
});
|
|
|
|
describe('generateZshCompletion', () => {
|
|
it('generates valid zsh completion', () => {
|
|
const script = generateZshCompletion();
|
|
expect(script).toContain('#compdef flynn');
|
|
expect(script).toContain('compdef _flynn flynn');
|
|
});
|
|
|
|
it('contains all subcommands', () => {
|
|
const script = generateZshCompletion();
|
|
for (const cmd of EXPECTED_SUBCOMMANDS) {
|
|
expect(script).toContain(cmd);
|
|
}
|
|
});
|
|
|
|
it('contains subcommand-specific options', () => {
|
|
const script = generateZshCompletion();
|
|
expect(script).toContain('--config');
|
|
expect(script).toContain('--fullscreen');
|
|
});
|
|
});
|
|
|
|
describe('generateFishCompletion', () => {
|
|
it('generates valid fish completion', () => {
|
|
const script = generateFishCompletion();
|
|
expect(script).toContain('complete -c flynn');
|
|
expect(script).toContain('__fish_use_subcommand');
|
|
});
|
|
|
|
it('contains all subcommands', () => {
|
|
const script = generateFishCompletion();
|
|
for (const cmd of EXPECTED_SUBCOMMANDS) {
|
|
expect(script).toContain(cmd);
|
|
}
|
|
});
|
|
|
|
it('contains subcommand-specific options', () => {
|
|
const script = generateFishCompletion();
|
|
expect(script).toContain('__fish_seen_subcommand_from start');
|
|
expect(script).toContain('__fish_seen_subcommand_from tui');
|
|
});
|
|
|
|
it('contains shell type completions for completion subcommand', () => {
|
|
const script = generateFishCompletion();
|
|
expect(script).toContain("'bash zsh fish'");
|
|
});
|
|
});
|