This commit is contained in:
36
packages/cli/tests/commands.test.ts
Normal file
36
packages/cli/tests/commands.test.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseCommand } from '../src/commands.js';
|
||||
|
||||
describe('parseCommand', () => {
|
||||
it('parses /model command with args', () => {
|
||||
const result = parseCommand('/model gpt-4o');
|
||||
expect(result).toEqual({ name: 'model', args: 'gpt-4o' });
|
||||
});
|
||||
|
||||
it('parses /exit (no args)', () => {
|
||||
const result = parseCommand('/exit');
|
||||
expect(result).toEqual({ name: 'exit', args: '' });
|
||||
});
|
||||
|
||||
it('parses /help', () => {
|
||||
const result = parseCommand('/help');
|
||||
expect(result).toEqual({ name: 'help', args: '' });
|
||||
});
|
||||
|
||||
it('returns null for regular messages', () => {
|
||||
expect(parseCommand('hello world')).toBeNull();
|
||||
expect(parseCommand('what is the weather?')).toBeNull();
|
||||
expect(parseCommand('')).toBeNull();
|
||||
expect(parseCommand(' some text ')).toBeNull();
|
||||
});
|
||||
|
||||
it('parses /clear', () => {
|
||||
const result = parseCommand('/clear');
|
||||
expect(result).toEqual({ name: 'clear', args: '' });
|
||||
});
|
||||
|
||||
it('parses /identity', () => {
|
||||
const result = parseCommand('/identity');
|
||||
expect(result).toEqual({ name: 'identity', args: '' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user