mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 12:15:57 +00:00
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
|
|
describe('cliproxy routing command dispatch', () => {
|
|
let calls: string[] = [];
|
|
|
|
beforeEach(() => {
|
|
calls = [];
|
|
|
|
mock.module('../../../src/commands/cliproxy/routing-subcommand', () => ({
|
|
handleRoutingStatus: async () => {
|
|
calls.push('status');
|
|
},
|
|
handleRoutingExplain: async () => {
|
|
calls.push('explain');
|
|
},
|
|
handleRoutingSet: async (args: string[]) => {
|
|
calls.push(`set:${args.join(' ')}`);
|
|
},
|
|
}));
|
|
});
|
|
|
|
afterEach(() => {
|
|
mock.restore();
|
|
});
|
|
|
|
async function loadHandleCliproxyCommand() {
|
|
const mod = await import(`../../../src/commands/cliproxy/index?test=${Date.now()}-${Math.random()}`);
|
|
return mod.handleCliproxyCommand;
|
|
}
|
|
|
|
it('shows routing status by default', async () => {
|
|
const handleCliproxyCommand = await loadHandleCliproxyCommand();
|
|
await handleCliproxyCommand(['routing']);
|
|
expect(calls).toEqual(['status']);
|
|
});
|
|
|
|
it('shows the routing explainer', async () => {
|
|
const handleCliproxyCommand = await loadHandleCliproxyCommand();
|
|
await handleCliproxyCommand(['routing', 'explain']);
|
|
expect(calls).toEqual(['explain']);
|
|
});
|
|
|
|
it('passes the explicit strategy to set', async () => {
|
|
const handleCliproxyCommand = await loadHandleCliproxyCommand();
|
|
await handleCliproxyCommand(['routing', 'set', 'fill-first']);
|
|
expect(calls).toEqual(['set:fill-first']);
|
|
});
|
|
});
|