Skip to content

Commit 9533634

Browse files
committed
test(mcp): add comprehensive tests + restructure to co-located pattern
Implements Issue #28 - First Adapter + Formatters (Tests) ## Test Coverage ### Formatters (30 tests) - **formatters.test.ts**: CompactFormatter + VerboseFormatter - Single/multiple result formatting - Token estimation - Empty result handling - Signature inclusion/exclusion - maxResults option - **utils.test.ts**: Token estimation utilities - Text/JSON token estimation - Truncation to token budgets - Whitespace normalization - Accuracy validation (~50% of actual) ### SearchAdapter (25 tests) - Tool definition validation - Query validation (empty, non-string) - Format validation (compact/verbose/invalid) - Limit validation (1-50 range) - Score threshold validation (0-1 range) - Search execution with mocked indexer - Token estimation comparison - Empty result handling ### Restructuring - ✅ Moved ALL tests from `tests/` to co-located `__tests__/` - ✅ Updated all import paths (simpler, cleaner) - ✅ Consistent with `packages/core` and `packages/subagents` - ✅ Works with root vitest.config.ts out of the box - ✅ 135 total tests pass (7 test files) ## Benefits - 🎯 Consistency across entire monorepo - 📁 Tests co-located with source code - 🔍 Easier discoverability - 🚀 Simpler import paths - ✅ Test discovery works automatically
1 parent 15e645f commit 9533634

File tree

11 files changed

+824
-11
lines changed

11 files changed

+824
-11
lines changed

packages/mcp-server/tests/adapters/adapter-registry.test.ts renamed to packages/mcp-server/src/adapters/__tests__/adapter-registry.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*/
44

55
import { beforeEach, describe, expect, it } from 'vitest';
6-
import { AdapterRegistry } from '../../src/adapters/adapter-registry';
7-
import type { AdapterContext } from '../../src/adapters/types';
6+
import { AdapterRegistry } from '../adapter-registry';
7+
import type { AdapterContext } from '../types';
88
import { MockAdapter } from './mock-adapter';
99

1010
describe('AdapterRegistry', () => {

packages/mcp-server/tests/adapters/mock-adapter.ts renamed to packages/mcp-server/src/adapters/__tests__/mock-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
* Simple echo adapter that returns what you send it
44
*/
55

6-
import { ToolAdapter } from '../../src/adapters/tool-adapter';
6+
import { ToolAdapter } from '../tool-adapter';
77
import type {
88
AdapterContext,
99
ToolDefinition,
1010
ToolExecutionContext,
1111
ToolResult,
1212
ValidationResult,
13-
} from '../../src/adapters/types';
13+
} from '../types';
1414

1515
export class MockAdapter extends ToolAdapter {
1616
readonly metadata = {

0 commit comments

Comments
 (0)