import { describe, it, expect } from 'vitest'; import { parseCommand, getHelpText } from './commands.js'; describe('parseCommand', () => { it('parses /quit command', () => { expect(parseCommand('/quit')).toEqual({ type: 'quit' }); expect(parseCommand('/exit')).toEqual({ type: 'quit' }); }); it('parses /reset command', () => { expect(parseCommand('/reset')).toEqual({ type: 'reset' }); expect(parseCommand('/clear')).toEqual({ type: 'reset' }); }); it('parses /help command', () => { expect(parseCommand('/help')).toEqual({ type: 'help' }); expect(parseCommand('/?')).toEqual({ type: 'help' }); }); it('parses /status command', () => { expect(parseCommand('/status')).toEqual({ type: 'status' }); }); it('parses /fullscreen command', () => { expect(parseCommand('/fullscreen')).toEqual({ type: 'fullscreen' }); expect(parseCommand('/fs')).toEqual({ type: 'fullscreen' }); }); it('parses /compact command', () => { expect(parseCommand('/compact')).toEqual({ type: 'compact' }); }); it('parses /usage command', () => { expect(parseCommand('/usage')).toEqual({ type: 'usage' }); }); it('parses /model command without argument', () => { expect(parseCommand('/model')).toEqual({ type: 'model' }); }); it('parses /model command with argument', () => { expect(parseCommand('/model local')).toEqual({ type: 'model', name: 'local' }); expect(parseCommand('/model opus')).toEqual({ type: 'model', name: 'opus' }); }); it('parses /backend command without argument', () => { expect(parseCommand('/backend')).toEqual({ type: 'backend' }); }); it('parses /backend command with argument', () => { expect(parseCommand('/backend llamacpp')).toEqual({ type: 'backend', provider: 'llamacpp' }); expect(parseCommand('/backend ollama')).toEqual({ type: 'backend', provider: 'ollama' }); }); it('parses /transfer command', () => { expect(parseCommand('/transfer telegram')).toEqual({ type: 'transfer', target: 'telegram' }); }); it('parses regular message', () => { expect(parseCommand('Hello Flynn')).toEqual({ type: 'message', content: 'Hello Flynn' }); }); it('returns null for empty input', () => { expect(parseCommand('')).toBeNull(); expect(parseCommand(' ')).toBeNull(); }); }); describe('getHelpText', () => { it('returns help text with all commands', () => { const help = getHelpText(); expect(help).toContain('/help'); expect(help).toContain('/model'); expect(help).toContain('/reset'); expect(help).toContain('/compact'); expect(help).toContain('/usage'); expect(help).toContain('/quit'); }); });