61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
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 /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 /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('/quit');
|
|
});
|
|
});
|