Skip to content

Commit 285827c

Browse files
committed
test: add coverage for endpoint URLs and agent-friendly aliases
- endpoints: verify quotaEndpoint uses v1/token_plan/remains for both regions - aliases: test --prompt, --query, --file, positional config set, search web, and speech generate all resolve correctly
1 parent 791eda4 commit 285827c

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

test/client/endpoints.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { describe, it, expect } from 'bun:test';
2+
import { quotaEndpoint } from '../../src/client/endpoints';
3+
4+
describe('quotaEndpoint', () => {
5+
it('uses token_plan/remains for global', () => {
6+
expect(quotaEndpoint('https://api.minimax.io')).toBe('https://api.minimax.io/v1/token_plan/remains');
7+
});
8+
9+
it('uses token_plan/remains for cn', () => {
10+
expect(quotaEndpoint('https://api.minimaxi.com')).toBe('https://api.minimaxi.com/v1/token_plan/remains');
11+
});
12+
});

test/commands/aliases.test.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { describe, it, expect } from 'bun:test';
2+
import { registry } from '../../src/registry';
3+
4+
describe('command aliases', () => {
5+
it('resolves "search web" same as "search query"', () => {
6+
const web = registry.resolve(['search', 'web']);
7+
const query = registry.resolve(['search', 'query']);
8+
expect(web.command).toBe(query.command);
9+
});
10+
11+
it('resolves "speech generate" same as "speech synthesize"', () => {
12+
const generate = registry.resolve(['speech', 'generate']);
13+
const synthesize = registry.resolve(['speech', 'synthesize']);
14+
expect(generate.command).toBe(synthesize.command);
15+
});
16+
});
17+
18+
describe('text chat --prompt alias', () => {
19+
it('accepts --prompt as alias for --message via dry run', async () => {
20+
const { default: chatCommand } = await import('../../src/commands/text/chat');
21+
22+
let output = '';
23+
const origLog = console.log;
24+
console.log = (msg: string) => { output += msg; };
25+
26+
try {
27+
await chatCommand.execute(
28+
{ apiKey: 'k', region: 'global', baseUrl: 'https://x', output: 'json', timeout: 10, verbose: false, quiet: false, noColor: true, yes: false, dryRun: true, nonInteractive: true, async: false },
29+
{ prompt: ['Hello from prompt'], quiet: false, verbose: false, noColor: true, yes: false, dryRun: true, help: false, nonInteractive: true, async: false },
30+
);
31+
const parsed = JSON.parse(output);
32+
expect(parsed.request.messages[0].content).toBe('Hello from prompt');
33+
} finally {
34+
console.log = origLog;
35+
}
36+
});
37+
});
38+
39+
describe('search --query alias', () => {
40+
it('accepts --query as alias for --q via dry run', async () => {
41+
const { default: queryCommand } = await import('../../src/commands/search/query');
42+
43+
let output = '';
44+
const origLog = console.log;
45+
console.log = (msg: string) => { output += msg; };
46+
47+
try {
48+
await queryCommand.execute(
49+
{ apiKey: 'k', region: 'global', baseUrl: 'https://x', output: 'json', timeout: 10, verbose: false, quiet: false, noColor: true, yes: false, dryRun: true, nonInteractive: true, async: false },
50+
{ query: 'test search', quiet: false, verbose: false, noColor: true, yes: false, dryRun: true, help: false, nonInteractive: true, async: false },
51+
);
52+
const parsed = JSON.parse(output);
53+
expect(parsed.request.q).toBe('test search');
54+
} finally {
55+
console.log = origLog;
56+
}
57+
});
58+
});
59+
60+
describe('config set positional args', () => {
61+
it('accepts positional key and value via dry run', async () => {
62+
const { default: setCommand } = await import('../../src/commands/config/set');
63+
64+
await expect(
65+
setCommand.execute(
66+
{ region: 'global', baseUrl: 'https://x', output: 'text', timeout: 10, verbose: false, quiet: false, noColor: true, yes: false, dryRun: true, nonInteractive: true, async: false },
67+
{ _positional: ['output', 'json'], quiet: false, verbose: false, noColor: true, yes: false, dryRun: true, help: false, nonInteractive: true, async: false },
68+
),
69+
).resolves.toBeUndefined();
70+
});
71+
});
72+
73+
describe('vision describe --file alias', () => {
74+
it('accepts --file as alias for --image via dry run', async () => {
75+
const { default: describeCommand } = await import('../../src/commands/vision/describe');
76+
77+
let output = '';
78+
const origWrite = process.stdout.write.bind(process.stdout);
79+
(process.stdout as NodeJS.WriteStream).write = (chunk: unknown) => { output += String(chunk); return true; };
80+
81+
try {
82+
await describeCommand.execute(
83+
{ apiKey: 'k', region: 'global', baseUrl: 'https://x', output: 'json', timeout: 10, verbose: false, quiet: false, noColor: true, yes: false, dryRun: true, nonInteractive: true, async: false },
84+
{ file: 'photo.jpg', quiet: false, verbose: false, noColor: true, yes: false, dryRun: true, help: false, nonInteractive: true, async: false },
85+
);
86+
const parsed = JSON.parse(output);
87+
expect(parsed.request.image).toBe('photo.jpg');
88+
} finally {
89+
(process.stdout as NodeJS.WriteStream).write = origWrite;
90+
}
91+
});
92+
});

0 commit comments

Comments
 (0)