Skip to content

Commit d433807

Browse files
NianJiuZstclaude
andcommitted
test: add unit tests for text repl command
Verify command import, metadata, option flags, and non-interactive mode rejection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9099e0f commit d433807

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

test/commands/text/repl.test.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { describe, it, expect } from 'bun:test';
2+
3+
describe('text repl command', () => {
4+
it('is importable and has correct metadata', async () => {
5+
const mod = await import('../../../src/commands/text/repl');
6+
const cmd = mod.default;
7+
8+
expect(cmd.name).toBe('text repl');
9+
expect(cmd.description).toContain('interactive');
10+
expect(cmd.options).toBeDefined();
11+
12+
const options = cmd.options!;
13+
expect(options.length).toBeGreaterThan(0);
14+
15+
// Verify key options exist
16+
const flagNames = options.map(o => o.flag);
17+
expect(flagNames.some(f => f.includes('model'))).toBe(true);
18+
expect(flagNames.some(f => f.includes('system'))).toBe(true);
19+
expect(flagNames.some(f => f.includes('max-tokens'))).toBe(true);
20+
});
21+
22+
it('rejects non-interactive mode', async () => {
23+
const mod = await import('../../../src/commands/text/repl');
24+
const cmd = mod.default;
25+
26+
const config = {
27+
region: 'global' as const,
28+
baseUrl: 'https://api.minimax.io',
29+
output: 'text' as const,
30+
timeout: 300,
31+
verbose: false,
32+
quiet: false,
33+
noColor: true,
34+
yes: false,
35+
dryRun: false,
36+
nonInteractive: true,
37+
async: false,
38+
};
39+
40+
const flags = {
41+
apiKey: 'sk-test',
42+
region: 'global' as const,
43+
baseUrl: 'https://api.minimax.io',
44+
output: 'text' as const,
45+
timeout: 300,
46+
quiet: false,
47+
verbose: false,
48+
noColor: true,
49+
dryRun: false,
50+
nonInteractive: true,
51+
help: false,
52+
version: false,
53+
async: false,
54+
yes: false,
55+
_positional: [] as string[],
56+
};
57+
58+
await expect(cmd.execute(config, flags)).rejects.toThrow('interactive');
59+
});
60+
});

0 commit comments

Comments
 (0)