Files
dbmole-mcp/packages/esmole-mcp/test/unit/cli.test.ts
T

33 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { parseArgs } from '../../src/cli.js'
describe('parseArgs', () => {
it('reads the path after a --config flag', () => {
expect(parseArgs(['--config', '/etc/esmole.json'], {})).toEqual({
configPath: '/etc/esmole.json'
})
})
it('falls back to ESMOLE_CONFIG when the flag is absent', () => {
expect(parseArgs([], { ESMOLE_CONFIG: '/env/path.json' })).toEqual({
configPath: '/env/path.json'
})
})
it('prefers the flag over ESMOLE_CONFIG', () => {
expect(parseArgs(['--config', '/flag.json'], { ESMOLE_CONFIG: '/env.json' })).toEqual({
configPath: '/flag.json'
})
})
it('ignores a trailing --config with no value', () => {
expect(parseArgs(['--config'], { ESMOLE_CONFIG: '/env.json' })).toEqual({
configPath: '/env.json'
})
})
it('returns undefined when neither flag nor env is set', () => {
expect(parseArgs([], {})).toEqual({ configPath: undefined })
})
})