mirror of
https://github.com/hanzoai/js-sdk.git
synced 2026-10-30 15:02:31 +00:00
33 lines
739 B
TypeScript
33 lines
739 B
TypeScript
import { parseCLIOptions } from '../src/options';
|
|
|
|
// Mock process.argv
|
|
const mockArgv = (args: string[]) => {
|
|
const originalArgv = process.argv;
|
|
process.argv = ['node', 'test.js', ...args];
|
|
return () => {
|
|
process.argv = originalArgv;
|
|
};
|
|
};
|
|
|
|
describe('parseCLIOptions', () => {
|
|
it('default parsing should be stdio', () => {
|
|
const cleanup = mockArgv([]);
|
|
|
|
const result = parseCLIOptions();
|
|
|
|
expect(result.transport).toBe('stdio');
|
|
|
|
cleanup();
|
|
});
|
|
|
|
it('using http transport with a port', () => {
|
|
const cleanup = mockArgv(['--transport=http', '--port=2222']);
|
|
|
|
const result = parseCLIOptions();
|
|
|
|
expect(result.transport).toBe('http');
|
|
expect(result.port).toBe(2222);
|
|
cleanup();
|
|
});
|
|
});
|