Import cc-haha and new-api into a single repository layout for unified delivery. Made-with: Cursor
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { parseLauncherArgs, resolveSidecarInvocation } from './launcherRouting'
|
|
|
|
describe('resolveSidecarInvocation', () => {
|
|
it('keeps explicit sidecar modes unchanged', () => {
|
|
expect(
|
|
resolveSidecarInvocation(
|
|
['server', '--host', '127.0.0.1'],
|
|
'/tmp/claude-sidecar',
|
|
),
|
|
).toEqual({
|
|
mode: 'server',
|
|
restArgs: ['--host', '127.0.0.1'],
|
|
defaultAppRoot: null,
|
|
})
|
|
})
|
|
|
|
it('defaults claude-haha invocations to cli mode', () => {
|
|
expect(
|
|
resolveSidecarInvocation(
|
|
['plugin', 'install', 'demo'],
|
|
'/Users/demo/.local/bin/claude-haha',
|
|
),
|
|
).toEqual({
|
|
mode: 'cli',
|
|
restArgs: ['plugin', 'install', 'demo'],
|
|
defaultAppRoot: '/Users/demo/.local/bin',
|
|
})
|
|
})
|
|
})
|
|
|
|
describe('parseLauncherArgs', () => {
|
|
it('falls back to the provided default app root', () => {
|
|
expect(
|
|
parseLauncherArgs(['plugin', 'install', 'demo'], '/Users/demo/.local/bin'),
|
|
).toEqual({
|
|
appRoot: '/Users/demo/.local/bin',
|
|
args: ['plugin', 'install', 'demo'],
|
|
})
|
|
})
|
|
|
|
it('lets explicit app root override the default', () => {
|
|
expect(
|
|
parseLauncherArgs(
|
|
['--app-root', '/tmp/app', 'plugin', 'install', 'demo'],
|
|
'/Users/demo/.local/bin',
|
|
),
|
|
).toEqual({
|
|
appRoot: '/tmp/app',
|
|
args: ['plugin', 'install', 'demo'],
|
|
})
|
|
})
|
|
})
|