Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions test/utils/mcpPath.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { normalizeMcpPath, getCompatibleMcpPaths } from '../../src/utils/mcpPath'

describe('normalizeMcpPath', () => {
it('returns default "/" when value is undefined', () => {
expect(normalizeMcpPath(undefined)).toBe('/')
})

it('returns default "/" when value is empty string', () => {
expect(normalizeMcpPath('')).toBe('/')
})

it('returns default "/" when value is whitespace', () => {
expect(normalizeMcpPath(' ')).toBe('/')
})

it('preserves value that starts with /', () => {
expect(normalizeMcpPath('/custom')).toBe('/custom')
})

it('prepends / when value does not start with /', () => {
expect(normalizeMcpPath('custom')).toBe('/custom')
})

it('trims whitespace from value', () => {
expect(normalizeMcpPath(' /path ')).toBe('/path')
})

it('uses custom default when value is empty', () => {
expect(normalizeMcpPath(undefined, '/alt')).toBe('/alt')
})
})

describe('getCompatibleMcpPaths', () => {
it('returns both "/" and "/mcp" for root path', () => {
const paths = getCompatibleMcpPaths('/')
expect(paths).toEqual(new Set(['/', '/mcp']))
})

it('returns both "/" and "/mcp" for /mcp path', () => {
const paths = getCompatibleMcpPaths('/mcp')
expect(paths).toEqual(new Set(['/', '/mcp']))
})

it('returns only the configured path for custom paths', () => {
const paths = getCompatibleMcpPaths('/custom')
expect(paths).toEqual(new Set(['/custom']))
})
})
Loading